'json', 'limit' => 'json', ]; public static function checkCodeIsUnique($code, $ignore_id = 0) { return self::query()->where('code', $code)->where('id', '<>', $ignore_id)->exists(); } /** * 根据code获取值 * @param $code * @return string|mixed */ public static function byCodeGetSetting($code) { // return Cache::tags('model')->remember('model:Setting:byCodeGetSetting:' . $code, Carbon::now()->addDays(1), function () use ($code) { $val = self::query()->where('code', $code)->value('value'); return $val; // }); } /** * 根据codes获取值 * @param array $codes * @return array|mixed */ public static function byCodesGetSettings(array $codes) { // return Cache::tags('model')->remember('model:Setting:byCodesGetSettings:' . arr2str($codes), Carbon::now()->addDays(1), function () use ($codes) { return self::query()->whereIn('code', $codes)->pluck('value', 'code')->toArray(); // }); } }