adds ternary checks on locations before pulling names in notifications

This commit is contained in:
Godfrey M 2025-02-06 11:34:14 -08:00
parent 39ce7b75ca
commit f41583fd59

View file

@ -79,7 +79,7 @@ class CheckinAssetNotification extends Notification
$fields = [ $fields = [
trans('general.administrator') => '<'.$admin->present()->viewUrl().'|'.$admin->present()->fullName().'>', trans('general.administrator') => '<'.$admin->present()->viewUrl().'|'.$admin->present()->fullName().'>',
trans('general.status') => $item->assetstatus->name, trans('general.status') => $item->assetstatus?->name,
trans('general.location') => ($item->location) ? $item->location->name : '', trans('general.location') => ($item->location) ? $item->location->name : '',
]; ];
@ -106,9 +106,9 @@ class CheckinAssetNotification extends Notification
->title(trans('mail.Asset_Checkin_Notification')) ->title(trans('mail.Asset_Checkin_Notification'))
->addStartGroupToSection('activityText') ->addStartGroupToSection('activityText')
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityText') ->fact(htmlspecialchars_decode($item->present()->name), '', 'activityText')
->fact(trans('mail.checked_into'), $item->location->name ? $item->location->name : '') ->fact(trans('mail.checked_into'), ($item->location) ? $item->location->name : '')
->fact(trans('mail.Asset_Checkin_Notification') . " by ", $admin->present()->fullName()) ->fact(trans('mail.Asset_Checkin_Notification') . " by ", $admin->present()->fullName())
->fact(trans('admin/hardware/form.status'), $item->assetstatus->name) ->fact(trans('admin/hardware/form.status'), $item->assetstatus?->name)
->fact(trans('mail.notes'), $note ?: ''); ->fact(trans('mail.notes'), $note ?: '');
} }
@ -116,9 +116,9 @@ class CheckinAssetNotification extends Notification
$message = trans('mail.Asset_Checkin_Notification'); $message = trans('mail.Asset_Checkin_Notification');
$details = [ $details = [
trans('mail.asset') => htmlspecialchars_decode($item->present()->name), trans('mail.asset') => htmlspecialchars_decode($item->present()->name),
trans('mail.checked_into') => $item->location->name ? $item->location->name : '', trans('mail.checked_into') => ($item->location) ? $item->location->name : '',
trans('mail.Asset_Checkin_Notification')." by " => $admin->present()->fullName(), trans('mail.Asset_Checkin_Notification')." by " => $admin->present()->fullName(),
trans('admin/hardware/form.status') => $item->assetstatus->name, trans('admin/hardware/form.status') => $item->assetstatus?->name,
trans('mail.notes') => $note ?: '', trans('mail.notes') => $note ?: '',
]; ];
@ -142,8 +142,8 @@ class CheckinAssetNotification extends Notification
Section::create( Section::create(
KeyValue::create( KeyValue::create(
trans('mail.checked_into') ?: '', trans('mail.checked_into') ?: '',
$item->location->name ? $item->location->name : '', ($item->location) ? $item->location->name : '',
trans('admin/hardware/form.status').": ".$item->assetstatus->name, trans('admin/hardware/form.status').": ".$item->assetstatus?->name,
) )
->onClick(route('hardware.show', $item->id)) ->onClick(route('hardware.show', $item->id))
) )