Handle shitty edge cases where an asset has no model without crashing

This commit is contained in:
snipe 2018-01-24 08:16:05 -08:00
parent 1dae7a2fe4
commit 2c2910d1dd

View file

@ -38,11 +38,11 @@ class AssetsTransformer
'status_type'=> e($asset->assetstatus->getStatuslabelType()),
'status_meta' => e($asset->present()->statusMeta),
] : null,
'category' => ($asset->model->category) ? [
'category' => (($asset->model) && ($asset->model->category)) ? [
'id' => (int) $asset->model->category->id,
'name'=> e($asset->model->category->name)
] : null,
'manufacturer' => ($asset->model->manufacturer) ? [
'manufacturer' => (($asset->model) && ($asset->model->manufacturer)) ? [
'id' => (int) $asset->model->manufacturer->id,
'name'=> e($asset->model->manufacturer->name)
] : null,