Skip to content

Commit

Permalink
some error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Mdabdullah3 committed Jan 5, 2024
1 parent ac654de commit 8169911
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions app/Http/Controllers/SubCategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,18 @@ public function store(StoreSubCategoryRequest $request): JsonResponse
public function show($id): JsonResponse
{
$subCategory = SubCategory::find($id);

return response()->json([
'status' => 'success',
'data' => $subCategory,
]);
if (!$subCategory) {
return response()->json([
'status' => 'No Data Found',
'code' => '404',
]);
} else {
return response()->json([
'status' => 'success',
'data' => $subCategory,
]);
}
}





/**
* Update the specified resource in storage.
*/
Expand Down

0 comments on commit 8169911

Please sign in to comment.