diff --git a/src/LaravelSiteSettingsProvider.php b/src/LaravelSiteSettingsProvider.php index 0a09bb4..dc5a1c6 100644 --- a/src/LaravelSiteSettingsProvider.php +++ b/src/LaravelSiteSettingsProvider.php @@ -3,6 +3,9 @@ namespace VI\LaravelSiteSettings; use Illuminate\Support\ServiceProvider; +use VI\LaravelSiteSettings\Models\LaravelSiteSetting; +use VI\LaravelSiteSettings\Models\LaravelSiteSettingGroup; +use VI\LaravelSiteSettings\Observers\LSSObserver; class LaravelSiteSettingsProvider extends ServiceProvider { @@ -30,9 +33,12 @@ public function boot() __DIR__ . '/../stubs/MoonShine/Resources/LaravelSiteSettingResource.php.stub' => app_path('MoonShine/Resources/LaravelSiteSettingResource.php'), ], 'moonshine'); + $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); + } - $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); + LaravelSiteSetting::observe(LSSObserver::class); + LaravelSiteSettingGroup::observe(LSSObserver::class); } diff --git a/src/Observers/LSSObserver.php b/src/Observers/LSSObserver.php new file mode 100644 index 0000000..4a7eb56 --- /dev/null +++ b/src/Observers/LSSObserver.php @@ -0,0 +1,38 @@ +forget(config('laravelsitesettings.cache_key')); + } + + + public function updated(Model $model) + { + cache()->forget(config('laravelsitesettings.cache_key')); + } + + + public function deleted(Model $model) + { + cache()->forget(config('laravelsitesettings.cache_key')); + } + + + public function restored(Model $model) + { + cache()->forget(config('laravelsitesettings.cache_key')); + } + + + public function forceDeleted(Model $model) + { + cache()->forget(config('laravelsitesettings.cache_key')); + } +} \ No newline at end of file