Skip to content

Commit 9fee554

Browse files
authored
fix: getting existing should be using findOrFail
1 parent f4b06b5 commit 9fee554

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Http/Api/Controller.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public function handleShowAction($id, $request = null, array $extraParams = [])
182182
$this->qualifyItemQuery();
183183

184184
try {
185-
$item = $this->builder->find($id, $fields);
185+
$item = $this->builder->findOrFail($id, $fields);
186186
$this->authoriseUserAction('view', $item);
187187
} catch (ModelNotFoundException $exception) {
188188
return $this->errorNotFound('Record not found');
@@ -206,7 +206,7 @@ public function handleUpdateAction($id, $request, array $extraParams = [])
206206
$this->handleCommonActions($request);
207207

208208
try {
209-
$item = $this->builder->find($id);
209+
$item = $this->builder->findOrFail($id);
210210
$this->authoriseUserAction('update', $item);
211211
} catch (ModelNotFoundException $exception) {
212212
return $this->errorNotFound('Record does not exist');
@@ -256,7 +256,7 @@ public function handleDestroyAction($id, $request = null)
256256
$this->qualifyItemQuery();
257257

258258
try {
259-
$item = $this->builder->find($id);
259+
$item = $this->builder->findOrFail($id);
260260
$this->authoriseUserAction('delete', $item);
261261
$item->delete();
262262
} catch (ModelNotFoundException $exception) {

0 commit comments

Comments
 (0)