mirror of
https://github.com/zoe-may/TDoG-Skin.git
synced 2024-11-24 13:52:19 +08:00
38 lines
668 B
PHP
38 lines
668 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Observers;
|
||
|
|
||
|
use App\Models\Scope;
|
||
|
use Illuminate\Support\Facades\Cache;
|
||
|
|
||
|
class ScopeObserver
|
||
|
{
|
||
|
/**
|
||
|
* Handle the Scope "saved" event.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function saved()
|
||
|
{
|
||
|
$this->refreshCachedScopes();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Handle the Scope "deleted" event.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function deleted()
|
||
|
{
|
||
|
$this->refreshCachedScopes();
|
||
|
}
|
||
|
|
||
|
protected function refreshCachedScopes()
|
||
|
{
|
||
|
Cache::forget('scopes');
|
||
|
Cache::rememberForever('scopes', function () {
|
||
|
return Scope::pluck('description', 'name')->toArray();
|
||
|
});
|
||
|
}
|
||
|
}
|