Use firstorfail on eloquent query to return error if asset is not found

This commit is contained in:
Ivan Nieto Vivanco 2023-03-29 19:11:28 -06:00
parent c9d1274edc
commit d10b7fd6af

View file

@ -463,7 +463,7 @@ class AssetsController extends Controller
{
$this->authorize('view', Asset::class);
$this->authorize('view', License::class);
$asset = Asset::where('id', $id)->withTrashed()->first();
$asset = Asset::where('id', $id)->withTrashed()->firstorfail();
$licenses = $asset->licenses()->get();
return (new LicensesTransformer())->transformLicenses($licenses, $licenses->count());