function globalParams($key = null, $default = false) { $params = []; try { $params = Cache::rememberForever('global_params', function () { if (!Schema::hasTable('settings')) { return collect(); } return Setting::get(); }); $params = $params->groupBy('site_id')->toArray(); } catch (\Exception $e) { } $siteId = site()->id; $params = isset($params[$siteId]) ? collect($params[$siteId])->pluck('value', 'key') : []; if ($key == null) { return $params; } return isset($params[$key]) ? $params[$key] : $default; }
public function settings() { if ($this->id != null) { return $this->hasMany(Setting::class); } return Setting::where('site_id', null); }
protected function process() { Cache::forget('global_params'); $global_params = GenericSetting::get(); Cache::forever('global_params', $global_params); }