Skip to content

Commit 25c091e

Browse files
author
ahmadhuss
committed
refactor: change find() to findOrFail method
* The Application will now not broke, but it gives you Server Error
1 parent 49e12a4 commit 25c091e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

app/Http/Controllers/CategoryController.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function show($id)
6161
*/
6262
public function edit($id)
6363
{
64-
$category = Category::find($id);
64+
$category = Category::findOrFail($id);
6565
return view('categories.edit', compact('category'));
6666
}
6767

@@ -74,7 +74,7 @@ public function edit($id)
7474
*/
7575
public function update(Request $request, $id)
7676
{
77-
$category = Category::find($id);
77+
$category = Category::findOrFail($id);
7878
$category->update([
7979
'name' => $request->name
8080
]);
@@ -89,7 +89,7 @@ public function update(Request $request, $id)
8989
*/
9090
public function destroy($id)
9191
{
92-
$category = Category::find($id);
92+
$category = Category::findOrFail($id);
9393
$category->delete();
9494
return redirect()->route('categories.index');
9595
}

0 commit comments

Comments
 (0)