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(); // }); } /** * 获取小程序配置 * @param $type * @return mixed */ public static function typeToWxappConfig($type) { // return Cache::remember("model:Setting:type2WxappConfig:{$type}", Carbon::now()->addWeek(), function () use ($type) { // switch ($type) { // // case 0: // //用户 // return [ // 'app_id' => Setting::byCodeGetSetting('system_weapp_user_app_id'), // 'app_secret' => Setting::byCodeGetSetting('system_weapp_user_app_secret') // ]; // break; // default: // abort(ResponseCodeEnum::SERVICE_OPERATION_ERROR, '小程序初始化配置失败'); // break; // } return [ 'app_id' => config('wechat.mini_program.default.app_id'), 'app_secret' => config('wechat.mini_program.default.secret'), ]; // }); } }