From 2707c399eac2bf90b3588712fb219b11f2c8fccd Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 8 Jan 2024 12:42:05 +0000 Subject: [PATCH] Check that the asset exists before trying to get properties Signed-off-by: snipe --- app/Http/Transformers/AssetMaintenancesTransformer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Transformers/AssetMaintenancesTransformer.php b/app/Http/Transformers/AssetMaintenancesTransformer.php index fa92640823..01ef2adb87 100644 --- a/app/Http/Transformers/AssetMaintenancesTransformer.php +++ b/app/Http/Transformers/AssetMaintenancesTransformer.php @@ -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,