From fb152b4dd45091fa82dae0c28d5cef709e5adee6 Mon Sep 17 00:00:00 2001 From: Leonardo Date: Sat, 4 May 2024 00:45:01 +0200 Subject: [PATCH] Allow events AutoDiscovery in Laravel 11 (#2829) --- 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(); + } }