Merge pull request #16540 from marcusmoore/bug/sc-28607
Early return null from location transformer for missing accessory
This commit is contained in:
commit
1d3069fe84
1 changed files with 15 additions and 6 deletions
|
@ -101,11 +101,8 @@ class LocationsTransformer
|
|||
$array = [
|
||||
'id' => $accessory_checkout->id,
|
||||
'assigned_to' => $accessory_checkout->assigned_to,
|
||||
'accessory' => [
|
||||
'id' => $accessory_checkout->accessory->id,
|
||||
'name' => $accessory_checkout->accessory->name,
|
||||
],
|
||||
'image' => ($accessory_checkout->accessory->image) ? Storage::disk('public')->url('accessories/'.e($accessory_checkout->accessory->image)) : null,
|
||||
'accessory' => $this->transformAccessory($accessory_checkout->accessory),
|
||||
'image' => ($accessory_checkout?->accessory?->image) ? Storage::disk('public')->url('accessories/' . e($accessory_checkout->accessory->image)) : null,
|
||||
'note' => $accessory_checkout->note ? e($accessory_checkout->note) : null,
|
||||
'created_by' => $accessory_checkout->adminuser ? [
|
||||
'id' => (int) $accessory_checkout->adminuser->id,
|
||||
|
@ -153,4 +150,16 @@ class LocationsTransformer
|
|||
return $array;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function transformAccessory(?Accessory $accessory): ?array
|
||||
{
|
||||
if ($accessory) {
|
||||
return [
|
||||
'id' => $accessory->id,
|
||||
'name' => $accessory->name,
|
||||
];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue