| @@ 21-31 (lines=11) @@ | ||
| 18 | Setting::updateOrCreate(['key' => $key, 'owner_id' => $this->id], ['value' => $value,]); |
|
| 19 | } |
|
| 20 | ||
| 21 | public function getSettings($key, $default = null) |
|
| 22 | { |
|
| 23 | $cache_key = config('settings.cache_prefix') . $key . '-' . $this->id; |
|
| 24 | $duration = config('settings.cache_duration'); |
|
| 25 | ||
| 26 | $value = Cache::remember($cache_key, $duration, function () use ($key) { |
|
| 27 | return Setting::where('key', $key)->where('owner_id', $this->id)->pluck('value')->first(); |
|
| 28 | }); |
|
| 29 | ||
| 30 | return $value ? $value : $default; |
|
| 31 | } |
|
| 32 | ||
| 33 | public function forgetSettings($key) |
|
| 34 | { |
|
| @@ 20-30 (lines=11) @@ | ||
| 17 | Setting::updateOrCreate(['key' => $key, 'owner_id' => null], ['value' => $value]); |
|
| 18 | } |
|
| 19 | ||
| 20 | public function get($key, $default = null) |
|
| 21 | { |
|
| 22 | $cache_key = config('settings.cache_prefix') . $key . '_global'; |
|
| 23 | $duration = config('settings.cache_duration'); |
|
| 24 | ||
| 25 | $value = Cache::remember($cache_key, $duration, function () use ($key) { |
|
| 26 | return Setting::where('key', $key)->whereNull('owner_id')->pluck('value')->first(); |
|
| 27 | }); |
|
| 28 | ||
| 29 | return $value ? $value : $default; |
|
| 30 | } |
|
| 31 | ||
| 32 | public function forget($key) |
|
| 33 | { |
|