-
app/Providers/EventServiceProvider.php
Open in GitHubuse App\Models\Affiliate; use App\Models\Announcement; use App\Models\Extension; use App\Models\Invoice; use App\Models\Ticket; use App\Models\TicketMessage; use App\Models\User; class EventServiceProvider extends ServiceProvider { // ... public function boot() { Invoice::observe(\App\Observers\InvoiceObserver::class); TicketMessage::observe(\App\Observers\TicketMessageObserver::class); Ticket::observe(\App\Observers\TicketObserver::class); User::observe(\App\Observers\UserObserver::class); Affiliate::observe(\App\Observers\AffiliateObserver::class); Announcement::observe(\App\Observers\AnnouncementObserver::class); try { foreach (Extension::where('enabled', true)->get() as $extension) { $module = $extension->namespace . 'Listeners'; if (!class_exists($module)) { continue; } Event::subscribe(new $module); } } catch (\Exception $e) { // If the database is not yet migrated, this will throw an exception. } } // ... }
-
app/Observers/UserObserver.php
Open in GitHubuse App\Events\User\UserCreated; use App\Events\User\UserUpdated; use App\Models\User; class UserObserver { public function created(User $user) { event(new UserCreated($user)); } public function updated(User $user) { event(new UserUpdated($user)); } // ... }