From d10b7fd6afce04daa9069912821fd2c1e4649cf2 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Wed, 29 Mar 2023 19:11:28 -0600 Subject: [PATCH] Use firstorfail on eloquent query to return error if asset is not found --- app/Http/Controllers/Api/AssetsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index d4ff0092ba..bad1947966 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -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());