Fixed a few inconsistencies in the API results (null vs empty string)

This commit is contained in:
snipe 2017-10-28 15:17:36 -07:00
parent 2244a4b3cf
commit 9687a78981
2 changed files with 4 additions and 4 deletions

View file

@ -256,7 +256,7 @@ class AssetsController extends Controller
*/
public function show($id)
{
if ($asset = Asset::withTrashed()->findOrFail($id)) {
if ($asset = Asset::with('assetstatus')->with('assignedTo')->withTrashed()->findOrFail($id)) {
$this->authorize('view', $asset);
return (new AssetsTransformer)->transformAsset($asset);
}

View file

@ -30,7 +30,7 @@ class AssetsTransformer
'id' => (int) $asset->model->id,
'name'=> e($asset->model->name)
] : 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) ? [
'id' => (int) $asset->assetstatus->id,
'name'=> e($asset->present()->statusText),
@ -135,8 +135,8 @@ class AssetsTransformer
'username' => e($asset->assigned->username),
'name' => e($asset->assigned->getFullNameAttribute()),
'first_name'=> e($asset->assigned->first_name),
'last_name'=> e($asset->assigned->last_name),
'employee_number' => e($asset->assigned->employee_num),
'last_name'=> ($asset->assigned->last_name) ? e($asset->assigned->last_name) : null,
'employee_number' => ($asset->assigned->employee_num) ? e($asset->assigned->employee_num) : null,
'type' => 'user'
] : null;
}