From 602b0b0ffb5e68eba83aaad8938b5150e1c372d2 Mon Sep 17 00:00:00 2001 From: Samuel De Backer Date: Tue, 13 Feb 2024 22:35:42 +0100 Subject: [PATCH] ObservedBy class attribute --- src/Models/News.php | 3 +++ src/Providers/ModuleServiceProvider.php | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Models/News.php b/src/Models/News.php index c2a53de..8f809ed 100644 --- a/src/Models/News.php +++ b/src/Models/News.php @@ -2,6 +2,7 @@ namespace TypiCMS\Modules\News\Models; +use Illuminate\Database\Eloquent\Attributes\ObservedBy; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Laracasts\Presenter\PresentableTrait; @@ -10,10 +11,12 @@ use Spatie\Translatable\HasTranslations; use TypiCMS\Modules\Core\Models\Base; use TypiCMS\Modules\Core\Models\File; +use TypiCMS\Modules\Core\Observers\SlugObserver; use TypiCMS\Modules\Core\Traits\HasFiles; use TypiCMS\Modules\Core\Traits\Historable; use TypiCMS\Modules\News\Presenters\ModulePresenter; +#[ObservedBy(SlugObserver::class)] class News extends Base implements Feedable { use HasFiles; diff --git a/src/Providers/ModuleServiceProvider.php b/src/Providers/ModuleServiceProvider.php index d521969..bb847d9 100644 --- a/src/Providers/ModuleServiceProvider.php +++ b/src/Providers/ModuleServiceProvider.php @@ -6,7 +6,6 @@ use Illuminate\Support\Facades\View; use Illuminate\Support\ServiceProvider; use TypiCMS\Modules\Core\Facades\TypiCMS; -use TypiCMS\Modules\Core\Observers\SlugObserver; use TypiCMS\Modules\News\Composers\SidebarViewComposer; use TypiCMS\Modules\News\Facades\News as NewsFacade; use TypiCMS\Modules\News\Models\News; @@ -27,9 +26,6 @@ public function boot(): void AliasLoader::getInstance()->alias('News', NewsFacade::class); - // Observers - News::observe(new SlugObserver()); - View::composer('core::admin._sidebar', SidebarViewComposer::class); /*