diff --git a/src/Models/Page.php b/src/Models/Page.php index e8b3c556..13049dc6 100644 --- a/src/Models/Page.php +++ b/src/Models/Page.php @@ -2,18 +2,23 @@ namespace TypiCMS\Modules\Core\Models; +use Illuminate\Database\Eloquent\Attributes\ObservedBy; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; use Laracasts\Presenter\PresentableTrait; use Spatie\Translatable\HasTranslations; use TypiCMS\Modules\Core\Facades\TypiCMS; +use TypiCMS\Modules\Core\Observers\AddToMenuObserver; +use TypiCMS\Modules\Core\Observers\HomePageObserver; +use TypiCMS\Modules\Core\Observers\UriObserver; use TypiCMS\Modules\Core\Presenters\PagePresenter; use TypiCMS\Modules\Core\Traits\HasFiles; use TypiCMS\Modules\Core\Traits\Historable; use TypiCMS\NestableCollection; use TypiCMS\NestableTrait; +#[ObservedBy([AddToMenuObserver::class, HomePageObserver::class, UriObserver::class])] class Page extends Base { use HasFiles; diff --git a/src/Models/Taxonomy.php b/src/Models/Taxonomy.php index b6c644ff..23835ae7 100644 --- a/src/Models/Taxonomy.php +++ b/src/Models/Taxonomy.php @@ -2,14 +2,17 @@ namespace TypiCMS\Modules\Core\Models; +use Illuminate\Database\Eloquent\Attributes\ObservedBy; use Illuminate\Database\Eloquent\Relations\HasMany; use Laracasts\Presenter\PresentableTrait; use Spatie\EloquentSortable\Sortable; use Spatie\EloquentSortable\SortableTrait; use Spatie\Translatable\HasTranslations; +use TypiCMS\Modules\Core\Observers\SlugObserver; use TypiCMS\Modules\Core\Presenters\TaxonomyPresenter; use TypiCMS\Modules\Core\Traits\Historable; +#[ObservedBy(SlugObserver::class)] class Taxonomy extends Base implements Sortable { use HasTranslations; diff --git a/src/Models/Term.php b/src/Models/Term.php index 176cc023..bbf4cf5e 100644 --- a/src/Models/Term.php +++ b/src/Models/Term.php @@ -2,15 +2,18 @@ namespace TypiCMS\Modules\Core\Models; +use Illuminate\Database\Eloquent\Attributes\ObservedBy; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Support\Facades\Route; use Laracasts\Presenter\PresentableTrait; use Spatie\EloquentSortable\Sortable; use Spatie\EloquentSortable\SortableTrait; use Spatie\Translatable\HasTranslations; +use TypiCMS\Modules\Core\Observers\SlugObserver; use TypiCMS\Modules\Core\Presenters\TermPresenter; use TypiCMS\Modules\Core\Traits\Historable; +#[ObservedBy(SlugObserver::class)] class Term extends Base implements Sortable { use HasTranslations; diff --git a/src/Providers/ModuleServiceProvider.php b/src/Providers/ModuleServiceProvider.php index 070c3d57..c37b30b3 100644 --- a/src/Providers/ModuleServiceProvider.php +++ b/src/Providers/ModuleServiceProvider.php @@ -45,11 +45,7 @@ use TypiCMS\Modules\Core\Models\Taxonomy; use TypiCMS\Modules\Core\Models\Term; use TypiCMS\Modules\Core\Models\User; -use TypiCMS\Modules\Core\Observers\AddToMenuObserver; use TypiCMS\Modules\Core\Observers\FileObserver; -use TypiCMS\Modules\Core\Observers\HomePageObserver; -use TypiCMS\Modules\Core\Observers\SlugObserver; -use TypiCMS\Modules\Core\Observers\UriObserver; use TypiCMS\Modules\Core\Services\FileUploader; use TypiCMS\Modules\Core\Services\TypiCMS; @@ -239,11 +235,6 @@ public function boot(): void |-------------------------------------------------------------------------- */ File::observe(new FileObserver(new FileUploader())); - Page::observe(new AddToMenuObserver()); - Page::observe(new HomePageObserver()); - Page::observe(new UriObserver()); - Taxonomy::observe(new SlugObserver()); - Term::observe(new SlugObserver()); /* |--------------------------------------------------------------------------