where( [ 'keyname' => $key ] )->first(); } if ($model) { // dump($model); if ($model->type === CONFIG_TYPE::TYPE_INT->valueInt()) { return (int)$model->value; } if ($model->type === CONFIG_TYPE::TYPE_FLOAT->valueInt()) { return (float)$model->value; } if ($model->type === CONFIG_TYPE::TYPE_TIME->valueInt()) { return (int)$model->value; } if ($model->type === CONFIG_TYPE::TYPE_IMG->valueInt()) { return Img::getAdminPicUrl($model->value); } if ($model->type === CONFIG_TYPE::TYPE_BOOL->valueInt()) { return boolval($model->value); } if ($model->type === CONFIG_TYPE::TYPE_IS->valueInt()) { return boolval($model->value); } if ($model->type === CONFIG_TYPE::TYPE_JSON->valueInt()) { return json_decode($model->value,true); } if ($model->type === CONFIG_TYPE::TYPE_EMBEDS->valueInt()) { return json_decode($model->value,true); } return $model->value; } return null; } /** * 获取分组kv * * @return mixed */ static public function getGroupKv() { return Cache::cacheCall([__FUNCTION__, __CLASS__,1], function () { $data = SysConfig::query()->distinct()->pluck('group','group')->toArray(); return $data; }, [], 3600, [self::CACHE_TAG]); } static public function getGroupKv2($group) { return Cache::cacheCall([__FUNCTION__, __CLASS__,$group,2], function ($group) { $data =SysConfig::query() ->where('group',$group) ->distinct() ->pluck('group2','group2') ->toArray(); // dd($data); return $data; }, [$group], 3600, [self::CACHE_TAG]); } /** * 获取客户端的可用 * * @return mixed */ static public function getClient() { return Cache::cacheCall([__FUNCTION__, __CLASS__], function () { $data = SysConfig::query()->where('is_client','=','1')->get(); $res = []; foreach ($data as $item){ $res[$item->keyname] = self::getValue($item->keyname,$item); } return $res; }, [], 1, [self::CACHE_TAG]); } /** * 获取分组的配置想 * @param $group * @return mixed */ static public function getByGroup($group) { return Cache::cacheCall([__FUNCTION__, __CLASS__], function ($group) { $data = SysConfig::query()->where('group','=',$group)->get(); $res = []; foreach ($data as $item){ $res[$item->keyname] = self::getValue($item->keyname,$item); } return $res; }, [$group], 10, [self::CACHE_TAG]); } static public function clear_cache() { CacheTag::tags_clear([self::CACHE_TAG]); } }