mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Fixed a few inconsistencies in the API results (null vs empty string)
This commit is contained in:
parent
2244a4b3cf
commit
9687a78981
|
@ -256,7 +256,7 @@ class AssetsController extends Controller
|
||||||
*/
|
*/
|
||||||
public function show($id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
if ($asset = Asset::withTrashed()->findOrFail($id)) {
|
if ($asset = Asset::with('assetstatus')->with('assignedTo')->withTrashed()->findOrFail($id)) {
|
||||||
$this->authorize('view', $asset);
|
$this->authorize('view', $asset);
|
||||||
return (new AssetsTransformer)->transformAsset($asset);
|
return (new AssetsTransformer)->transformAsset($asset);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ class AssetsTransformer
|
||||||
'id' => (int) $asset->model->id,
|
'id' => (int) $asset->model->id,
|
||||||
'name'=> e($asset->model->name)
|
'name'=> e($asset->model->name)
|
||||||
] : null,
|
] : null,
|
||||||
'model_number' => ($asset->model) ? e($asset->model->model_number) : null,
|
'model_number' => (($asset->model) && ($asset->model->model_number)) ? e($asset->model->model_number) : null,
|
||||||
'status_label' => ($asset->assetstatus) ? [
|
'status_label' => ($asset->assetstatus) ? [
|
||||||
'id' => (int) $asset->assetstatus->id,
|
'id' => (int) $asset->assetstatus->id,
|
||||||
'name'=> e($asset->present()->statusText),
|
'name'=> e($asset->present()->statusText),
|
||||||
|
@ -135,8 +135,8 @@ class AssetsTransformer
|
||||||
'username' => e($asset->assigned->username),
|
'username' => e($asset->assigned->username),
|
||||||
'name' => e($asset->assigned->getFullNameAttribute()),
|
'name' => e($asset->assigned->getFullNameAttribute()),
|
||||||
'first_name'=> e($asset->assigned->first_name),
|
'first_name'=> e($asset->assigned->first_name),
|
||||||
'last_name'=> e($asset->assigned->last_name),
|
'last_name'=> ($asset->assigned->last_name) ? e($asset->assigned->last_name) : null,
|
||||||
'employee_number' => e($asset->assigned->employee_num),
|
'employee_number' => ($asset->assigned->employee_num) ? e($asset->assigned->employee_num) : null,
|
||||||
'type' => 'user'
|
'type' => 'user'
|
||||||
] : null;
|
] : null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue