Skip to content

Commit

Permalink
ObservedBy class attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
sdebacker committed Feb 13, 2024
1 parent 4c0e082 commit 1b315d6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/Models/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/Models/Taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/Models/Term.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 0 additions & 9 deletions src/Providers/ModuleServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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());

/*
|--------------------------------------------------------------------------
Expand Down

0 comments on commit 1b315d6

Please sign in to comment.