orchidsoftware / platform

Orchid is a @laravel package that allows for rapid application development of back-office applications, admin/user panels, and dashboards.
https://orchid.software
MIT License
4.26k stars 631 forks source link

Allow events AutoDiscovery in Laravel 11 #2829

Closed DocLM closed 1 month ago

DocLM commented 2 months ago

Fixes #2828

Proposed Changes

Laravel 11 automatically disable events auto discovery if a different instance of EventServiceProvider is loaded. This is handle by shouldDiscoverEvents method at line 137 in Illuminate/Foundation/Support/Providers/EventServiceProvider.php. Since Orchid extend and register it's own version of EventServiceProvider the class check at get_class($this) === __CLASS__ starts to fail since it's executed with an instance of Orchid EventsServiceProvider.

I propose to override the shouldDiscoverEvents in order to match get_class and __CLASS__ values and re-enable the auto discovery.