From e47972731b5d5bb4b3111ec54cb74139112b8dc0 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 7 Aug 2025 15:12:23 -0700 Subject: [PATCH] fixed target name for checkouts with licenses and assets --- app/Mail/CheckoutAssetMail.php | 10 +++++++++- app/Mail/CheckoutLicenseMail.php | 10 +++++++++- resources/views/mail/markdown/checkout-asset.blade.php | 2 +- .../views/mail/markdown/checkout-license.blade.php | 2 +- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/Mail/CheckoutAssetMail.php b/app/Mail/CheckoutAssetMail.php index 7ac20861ed..6886a8741a 100644 --- a/app/Mail/CheckoutAssetMail.php +++ b/app/Mail/CheckoutAssetMail.php @@ -30,10 +30,18 @@ class CheckoutAssetMail extends Mailable $this->item = $asset; $this->admin = $checkedOutBy; $this->note = $note; - $this->target = $checkedOutTo; $this->acceptance = $acceptance; $this->settings = Setting::getSettings(); + $this->target = $checkedOutTo; + + // 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(); + } + else if($this->target instanceof Asset){ + $this->target = $this->target->assignedto->present()->fullName(); + } $this->last_checkout = ''; $this->expected_checkin = ''; diff --git a/app/Mail/CheckoutLicenseMail.php b/app/Mail/CheckoutLicenseMail.php index 9462c6c332..eb0bb341b5 100644 --- a/app/Mail/CheckoutLicenseMail.php +++ b/app/Mail/CheckoutLicenseMail.php @@ -2,6 +2,7 @@ namespace App\Mail; +use App\Models\Asset; use App\Models\LicenseSeat; use App\Models\Setting; use App\Models\User; @@ -25,9 +26,16 @@ class CheckoutLicenseMail extends Mailable $this->item = $licenseSeat; $this->admin = $checkedOutBy; $this->note = $note; - $this->target = $checkedOutTo; $this->acceptance = $acceptance; $this->settings = Setting::getSettings(); + $this->target = $checkedOutTo; + + if($this->target instanceof User){ + $this->target = $this->target->present()->fullName(); + } + elseif($this->target instanceof Asset){ + $this->target = $this->target->assignedto->present()->fullName(); + } } /** diff --git a/resources/views/mail/markdown/checkout-asset.blade.php b/resources/views/mail/markdown/checkout-asset.blade.php index b72e17e11a..5c53f188fc 100644 --- a/resources/views/mail/markdown/checkout-asset.blade.php +++ b/resources/views/mail/markdown/checkout-asset.blade.php @@ -1,5 +1,5 @@ @component('mail::message') -# {{ trans('mail.hello') }}{{ $target->assignedto?->present()->fullName() ? ' ' . $target->assignedto->present()->fullName() . ',' : ',' }} +# {{ trans('mail.hello').' '.$target.','}} {{ $introduction_line }} diff --git a/resources/views/mail/markdown/checkout-license.blade.php b/resources/views/mail/markdown/checkout-license.blade.php index 5d982d1b1b..373d11e8eb 100644 --- a/resources/views/mail/markdown/checkout-license.blade.php +++ b/resources/views/mail/markdown/checkout-license.blade.php @@ -1,5 +1,5 @@ @component('mail::message') -# {{ trans('mail.hello') }} {{ $target->present()->fullName() }}, +# {{ trans('mail.hello').' '.$target.','}} {{ trans('mail.new_item_checked') }}