laravel / ideas

Issues board used for Laravel internals discussions.
939 stars 28 forks source link

Automatic Observer Discovery #2464

Open modernben opened 3 years ago

modernben commented 3 years ago

It would be really nice if Laravel had automatic observer discovery similar to that of automatic policy discovery.

This would remove the need to add the following to the EventServiceProvider, keeping that file clean.

public function boot()
{
    User::observe(UserObserver::class);
}

It would use the same educated guess that the policies use for observers that live in the App\Observers namespace. {Model}::observe({Model}Observer::class)