<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Config\Driver; use Illuminate\Support\Facades\Cache; use ModStart\Admin\Model\Config; use ModStart\Core\Config\MConfig; use ModStart\Core\Dao\ModelUtil; class DatabaseMConfig extends MConfig { const CACHE_PREFIX = 'config:'; public function get($oMJcb, $Z1lY2 = '', $vy0W0 = true) { goto PWG9r; V9BuA: $S7oCu = self::CACHE_PREFIX . $oMJcb; goto a00QK; pGIr5: return $Z1lY2; goto hZHOL; uJ7SR: if ($vy0W0) { $cBDsM = Cache::get($S7oCu); if (null !== $cBDsM) { if (null === $cBDsM || '' === $cBDsM) { return $Z1lY2; } return $cBDsM; } } goto LEfl8; PWG9r: if (null === $Z1lY2) { $Z1lY2 = ''; } goto V9BuA; LEfl8: if (null === $cBDsM) { $N7PdT = ModelUtil::get('config', array('key' => $oMJcb)); if ($N7PdT) { goto SNXHb; DRbF0: if (null === $N7PdT['value'] || '' === $N7PdT['value']) { return $Z1lY2; } goto oRJuD; oRJuD: return $N7PdT['value']; goto mnIBc; SNXHb: Cache::forever($S7oCu, $N7PdT['value']); goto DRbF0; mnIBc: } else { Cache::forever($S7oCu, $Z1lY2); } } goto pGIr5; a00QK: $cBDsM = null; goto uJ7SR; hZHOL: } public function set($oMJcb, $cBDsM) { goto HnTr6; kjbPj: if ($N7PdT) { ModelUtil::update('config', array('id' => $N7PdT['id']), array('value' => $cBDsM)); } else { ModelUtil::insert('config', array('key' => $oMJcb, 'value' => $cBDsM)); } goto TuMEE; TuMEE: $S7oCu = self::CACHE_PREFIX . $oMJcb; goto BlY4w; HnTr6: $N7PdT = ModelUtil::get('config', array('key' => $oMJcb)); goto kjbPj; BlY4w: Cache::forget($S7oCu); goto pHFTc; pHFTc: } public function remove($oMJcb) { goto jnGpH; jnGpH: $N7PdT = ModelUtil::get('config', array('key' => $oMJcb)); goto j1Ese; j1Ese: if ($N7PdT) { ModelUtil::delete('config', array('id' => $N7PdT['id'])); } goto O6t1P; KnJNZ: Cache::forget($S7oCu); goto mACEk; O6t1P: $S7oCu = self::CACHE_PREFIX . $oMJcb; goto KnJNZ; mACEk: } public function has($oMJcb) { $N7PdT = ModelUtil::get('config', array('key' => $oMJcb)); return !!$N7PdT; } public function all($hyTx0 = null) { goto Z_9DW; k9fJX: $lrt5F = $nYIOS->get(array('key', 'value'))->toArray(); goto xDAMh; Z_9DW: $nYIOS = Config::query(); goto gjmiI; xDAMh: return $lrt5F; goto QuOMf; QuOMf: return array_column($lrt5F, 'value', 'key'); goto qlovf; gjmiI: if (null !== $hyTx0) { $nYIOS->where('key', 'like', $hyTx0 . '%'); } goto k9fJX; qlovf: } }