From 9ea91373d00dcc4075f8a6430a1418fb529b76cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Fran=C3=A7a?= Date: Fri, 22 Mar 2024 16:48:06 -0300 Subject: [PATCH] Enable to pass any additional parameters to Notification class --- src/Notifications/VerificationCodeCreated.php | 2 +- src/Notifications/VerificationCodeCreatedInterface.php | 2 +- src/VerificationCodeManager.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Notifications/VerificationCodeCreated.php b/src/Notifications/VerificationCodeCreated.php index c5aa657..876abca 100644 --- a/src/Notifications/VerificationCodeCreated.php +++ b/src/Notifications/VerificationCodeCreated.php @@ -13,7 +13,7 @@ class VerificationCodeCreated extends Notification implements ShouldQueue, Verif public $code; - public function __construct(string $code) + public function __construct(string $code, ...$args) { $this->code = $code; } diff --git a/src/Notifications/VerificationCodeCreatedInterface.php b/src/Notifications/VerificationCodeCreatedInterface.php index 6f44b03..5ae116a 100644 --- a/src/Notifications/VerificationCodeCreatedInterface.php +++ b/src/Notifications/VerificationCodeCreatedInterface.php @@ -4,5 +4,5 @@ interface VerificationCodeCreatedInterface { - public function __construct(string $code); + public function __construct(string $code, ...$args); } diff --git a/src/VerificationCodeManager.php b/src/VerificationCodeManager.php index 2f45dac..7301471 100644 --- a/src/VerificationCodeManager.php +++ b/src/VerificationCodeManager.php @@ -15,7 +15,7 @@ class VerificationCodeManager /** * Create and send a verification code. */ - public function send(string $verifiable, string $channel = 'mail') : void + public function send(string $verifiable, string $channel = 'mail', ...$args) : void { if ($this->isTestVerifiable($verifiable)) { return; @@ -24,7 +24,7 @@ public function send(string $verifiable, string $channel = 'mail') : void $code = $this->getModelClass()::createFor($verifiable); $notificationClass = $this->getNotificationClass(); - $notification = new $notificationClass($code); + $notification = new $notificationClass($code, $args); if ($notification instanceof ShouldQueue) { $notification->onQueue(config('verification-code.queue', null));