$name])->find(); if(!$config){ $configFilePath = APP_PATH . 'common/model/fill/data/app_config.php'; $config = require($configFilePath); if($config){ foreach ($config as $item){ if($item['name'] == $name){ Cache::set(\app\common\constant\cache\Keys::APP_CONFIG.$name,json_decode($item['value'],true)); return json_decode($item['value'],true); } } } Cache::set(\app\common\constant\cache\Keys::APP_CONFIG.$name,\app\common\model\app\ConfigDefault::$agent); //获取默认配置 return \app\common\model\app\ConfigDefault::$agent; }else{ Cache::set(\app\common\constant\cache\Keys::APP_CONFIG.$name,json_decode($config['value'],true)); return json_decode($config['value'],true); } } /** * 设置配置 * @param $name * @param $value * @return bool */ public static function setConfig($name,$value){ $config = self::where([ 'name'=>$name ])->find(); $value = json_encode($value,true); if(!$config){ self::insert([ 'name'=>$name, 'uniacid'=>UNIACID, 'createtime'=>time(), 'value'=>$value ]); }else{ self::where([ 'name'=>$name ])->cache(\app\common\constant\cache\Keys::APP_CONFIG.$name)->update([ 'value'=>$value ]); } return true; } }