Skip to content

Commit

Permalink
add condition for null car
Browse files Browse the repository at this point in the history
  • Loading branch information
stazrouti committed Sep 16, 2024
1 parent efd32f9 commit 4808224
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rental-car-backend/app/Http/Controllers/CarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public function show($id)
{
// Find the car by ID along with its images using Eager Loading
$car = Car::with('images')->find($id);

if (!$car) {
return response()->json(['message' => 'Car not found'], 404);
}

// If the car doesn't exist, return a 404 error
if (!$car) {
Expand Down

0 comments on commit 4808224

Please sign in to comment.