Skip to content

Commit b54d68e

Browse files
authored
Merge pull request #16212 from Godmartinz/ternary-checks-on-location-in-notifications
adds ternaries on check in/out hardware notifications
2 parents 4ae2126 + f41583f commit b54d68e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

app/Notifications/CheckinAssetNotification.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function toSlack()
7979

8080
$fields = [
8181
trans('general.administrator') => '<'.$admin->present()->viewUrl().'|'.$admin->present()->fullName().'>',
82-
trans('general.status') => $item->assetstatus->name,
82+
trans('general.status') => $item->assetstatus?->name,
8383
trans('general.location') => ($item->location) ? $item->location->name : '',
8484
];
8585

@@ -106,19 +106,19 @@ public function toMicrosoftTeams()
106106
->title(trans('mail.Asset_Checkin_Notification'))
107107
->addStartGroupToSection('activityText')
108108
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityText')
109-
->fact(trans('mail.checked_into'), $item->location->name ? $item->location->name : '')
109+
->fact(trans('mail.checked_into'), ($item->location) ? $item->location->name : '')
110110
->fact(trans('mail.Asset_Checkin_Notification') . " by ", $admin->present()->fullName())
111-
->fact(trans('admin/hardware/form.status'), $item->assetstatus->name)
111+
->fact(trans('admin/hardware/form.status'), $item->assetstatus?->name)
112112
->fact(trans('mail.notes'), $note ?: '');
113113
}
114114

115115

116116
$message = trans('mail.Asset_Checkin_Notification');
117117
$details = [
118118
trans('mail.asset') => htmlspecialchars_decode($item->present()->name),
119-
trans('mail.checked_into') => $item->location->name ? $item->location->name : '',
119+
trans('mail.checked_into') => ($item->location) ? $item->location->name : '',
120120
trans('mail.Asset_Checkin_Notification')." by " => $admin->present()->fullName(),
121-
trans('admin/hardware/form.status') => $item->assetstatus->name,
121+
trans('admin/hardware/form.status') => $item->assetstatus?->name,
122122
trans('mail.notes') => $note ?: '',
123123
];
124124

@@ -142,8 +142,8 @@ public function toGoogleChat()
142142
Section::create(
143143
KeyValue::create(
144144
trans('mail.checked_into') ?: '',
145-
$item->location->name ? $item->location->name : '',
146-
trans('admin/hardware/form.status').": ".$item->assetstatus->name,
145+
($item->location) ? $item->location->name : '',
146+
trans('admin/hardware/form.status').": ".$item->assetstatus?->name,
147147
)
148148
->onClick(route('hardware.show', $item->id))
149149
)

0 commit comments

Comments
 (0)