From 123cdeb858a8148cd8210847fcb39e635b7dc2bf Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 17 Oct 2024 12:39:48 -0700 Subject: [PATCH] add email check to listener --- app/Listeners/CheckoutableListener.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Listeners/CheckoutableListener.php b/app/Listeners/CheckoutableListener.php index 3e23259fb6..ff76ae020e 100644 --- a/app/Listeners/CheckoutableListener.php +++ b/app/Listeners/CheckoutableListener.php @@ -17,6 +17,7 @@ use App\Models\Component; use App\Models\Consumable; use App\Models\LicenseSeat; use App\Models\Setting; +use App\Models\User; use App\Notifications\CheckinAccessoryNotification; use App\Notifications\CheckinAssetNotification; use App\Notifications\CheckinLicenseSeatNotification; @@ -64,13 +65,14 @@ class CheckoutableListener * 2. The item has a EULA * 3. The item should send an email at check-in/check-out */ - + if ($notifiable instanceof User && $notifiable->email != '') { if ($event->checkoutable->requireAcceptance() || $event->checkoutable->getEula() || (method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email())) { Mail::to($notifiable)->send($mailable); - Log::info('Sending email, Locale: ' .($event->checkedOutTo->locale ?? 'default')); + Log::info('Sending email, Locale: ' . ($event->checkedOutTo->locale ?? 'default')); } + } // Send Webhook notification if ($this->shouldSendWebhookNotification()) {