From 5c55c90d68a1a5ed5e5b3dcf88ccf0bc2d5876b6 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 7 Aug 2025 15:27:50 -0700 Subject: [PATCH] add null checks to target --- app/Mail/CheckoutAssetMail.php | 5 +++-- app/Mail/CheckoutLicenseMail.php | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Mail/CheckoutAssetMail.php b/app/Mail/CheckoutAssetMail.php index 6886a8741a..44e0c06100 100644 --- a/app/Mail/CheckoutAssetMail.php +++ b/app/Mail/CheckoutAssetMail.php @@ -24,6 +24,7 @@ class CheckoutAssetMail extends Mailable /** * Create a new message instance. + * @throws \Exception */ public function __construct(Asset $asset, $checkedOutTo, User $checkedOutBy, $acceptance, $note, bool $firstTimeSending = true) { @@ -37,10 +38,10 @@ class CheckoutAssetMail extends Mailable // Location is a target option, but there are no emails currently associated with locations. if($this->target instanceof User){ - $this->target = $this->target->present()->fullName(); + $this->target = $this->target->present()?->fullName(); } else if($this->target instanceof Asset){ - $this->target = $this->target->assignedto->present()->fullName(); + $this->target = $this->target->assignedto?->present()?->fullName(); } $this->last_checkout = ''; diff --git a/app/Mail/CheckoutLicenseMail.php b/app/Mail/CheckoutLicenseMail.php index eb0bb341b5..e0701413e7 100644 --- a/app/Mail/CheckoutLicenseMail.php +++ b/app/Mail/CheckoutLicenseMail.php @@ -31,10 +31,10 @@ class CheckoutLicenseMail extends Mailable $this->target = $checkedOutTo; if($this->target instanceof User){ - $this->target = $this->target->present()->fullName(); + $this->target = $this->target->present()?->fullName(); } elseif($this->target instanceof Asset){ - $this->target = $this->target->assignedto->present()->fullName(); + $this->target = $this->target->assignedto?->present()?->fullName(); } }