From 3e3a00c17fb7cfb8b476a320fa6207f22279f077 Mon Sep 17 00:00:00 2001 From: BB Date: Wed, 23 Apr 2025 03:01:38 -0400 Subject: [PATCH] remove hardcoded config entries in the service provider, so that events listed in config are automatically listening --- src/LaravelAuthenticationLogServiceProvider.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/LaravelAuthenticationLogServiceProvider.php b/src/LaravelAuthenticationLogServiceProvider.php index 73722fb..36de11a 100644 --- a/src/LaravelAuthenticationLogServiceProvider.php +++ b/src/LaravelAuthenticationLogServiceProvider.php @@ -28,9 +28,10 @@ public function configurePackage(Package $package): void ->hasCommand(PurgeAuthenticationLogCommand::class); $events = $this->app->make(Dispatcher::class); - $events->listen(config('authentication-log.events.login', Login::class), config('authentication-log.listeners.login', LoginListener::class)); - $events->listen(config('authentication-log.events.failed', Failed::class), config('authentication-log.listeners.failed', FailedLoginListener::class)); - $events->listen(config('authentication-log.events.logout', Logout::class), config('authentication-log.listeners.logout', LogoutListener::class)); - $events->listen(config('authentication-log.events.other-device-logout', OtherDeviceLogout::class), config('authentication-log.listeners.other-device-logout', OtherDeviceLogoutListener::class)); + $eventKeys = array_keys(config("authentication-log.events")); + foreach ($eventKeys as $key) { + $events->listen(config("authentication-log.events")[$key], config("authentication-log.listeners")[$key]); + } + } }