Check that the asset exists before trying to get properties

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-01-08 12:42:05 +00:00
parent 6ebbd2dc30
commit 2707c399ea

View file

@ -45,7 +45,7 @@ class AssetMaintenancesTransformer
'name'=> e($assetmaintenance->asset->location->name),
] : null,
'rtd_location' => ($assetmaintenance->asset->defaultLoc) ? [
'rtd_location' => (($assetmaintenance->asset) && ($assetmaintenance->asset->defaultLoc)) ? [
'id' => (int) $assetmaintenance->asset->defaultLoc->id,
'name'=> e($assetmaintenance->asset->defaultLoc->name),
] : null,