From 2ad69829acf553dd57fb46125c03c2d4115ed91d Mon Sep 17 00:00:00 2001 From: Leonardo Medici Date: Thu, 2 May 2024 14:41:57 +0200 Subject: [PATCH] Allow events AutoDiscovery in Laravel 11 --- src/Platform/Providers/EventServiceProvider.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Platform/Providers/EventServiceProvider.php b/src/Platform/Providers/EventServiceProvider.php index 7b4dc79257..549224f76d 100644 --- a/src/Platform/Providers/EventServiceProvider.php +++ b/src/Platform/Providers/EventServiceProvider.php @@ -20,4 +20,18 @@ class EventServiceProvider extends ServiceProvider LockUserForLogin::class, ], ]; + + /** + * Determine if events and listeners should be automatically discovered. + * + * @return bool + */ + public function shouldDiscoverEvents() + { + if(isset(static::$shouldDiscoverEvents)) { + return get_class($this) === __CLASS__ && static::$shouldDiscoverEvents === true; + } + + return parent::shouldDiscoverEvents(); + } }