Skip to content

Commit 123cdeb

Browse files
committed
add email check to listener
1 parent 496b44e commit 123cdeb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

app/Listeners/CheckoutableListener.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use App\Models\Consumable;
1818
use App\Models\LicenseSeat;
1919
use App\Models\Setting;
20+
use App\Models\User;
2021
use App\Notifications\CheckinAccessoryNotification;
2122
use App\Notifications\CheckinAssetNotification;
2223
use App\Notifications\CheckinLicenseSeatNotification;
@@ -64,13 +65,14 @@ public function onCheckedOut($event)
6465
* 2. The item has a EULA
6566
* 3. The item should send an email at check-in/check-out
6667
*/
67-
68+
if ($notifiable instanceof User && $notifiable->email != '') {
6869
if ($event->checkoutable->requireAcceptance() || $event->checkoutable->getEula() ||
6970
(method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email())) {
7071

7172
Mail::to($notifiable)->send($mailable);
72-
Log::info('Sending email, Locale: ' .($event->checkedOutTo->locale ?? 'default'));
73+
Log::info('Sending email, Locale: ' . ($event->checkedOutTo->locale ?? 'default'));
7374
}
75+
}
7476

7577
// Send Webhook notification
7678
if ($this->shouldSendWebhookNotification()) {

0 commit comments

Comments
 (0)