From 7c3e551dda0d7f1940ad6df8cef5a1deeed10a24 Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Fri, 9 Oct 2026 14:00:20 +0800 Subject: [PATCH] fix(places): return 404 when a place isn't found GET, PUT and DELETE /v1/places/{id} answered 400 for an unknown or foreign place, unlike orders, vehicles, drivers and fleets. Fixes #361 --- server/src/Http/Controllers/Api/v1/PlaceController.php | 6 +++--- server/tests/ApiPlaceControllerContractsTest.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/src/Http/Controllers/Api/v1/PlaceController.php b/server/src/Http/Controllers/Api/v1/PlaceController.php index dffb82b51..43c19bb6a 100644 --- a/server/src/Http/Controllers/Api/v1/PlaceController.php +++ b/server/src/Http/Controllers/Api/v1/PlaceController.php @@ -146,7 +146,7 @@ public function update($id, UpdatePlaceRequest $request) try { $place = $this->findPlaceOrFail($id); } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $exception) { - return $this->apiError('Place resource not found.'); + return $this->apiError('Place resource not found.', 404); } // get request input @@ -253,7 +253,7 @@ public function find($id, Request $request) try { $place = $this->findPlaceOrFail($id); } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $exception) { - return $this->apiError('Place resource not found.'); + return $this->apiError('Place resource not found.', 404); } return $this->placeResource($place); @@ -269,7 +269,7 @@ public function delete($id, Request $request) try { $place = $this->findPlaceOrFail($id); } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $exception) { - return $this->apiError('Place resource not found.'); + return $this->apiError('Place resource not found.', 404); } $place->delete(); diff --git a/server/tests/ApiPlaceControllerContractsTest.php b/server/tests/ApiPlaceControllerContractsTest.php index 876329d9e..24f565876 100644 --- a/server/tests/ApiPlaceControllerContractsTest.php +++ b/server/tests/ApiPlaceControllerContractsTest.php @@ -537,5 +537,5 @@ function fleetopsApiPlace(array $attributes = []): FleetOpsApiPlaceEndpointFake ? $controller->update('missing-place', fleetopsUpdatePlaceRequest([])) : $controller->{$method}('missing-place', new Request()); - expect($response)->toBe(['apiError' => 'Place resource not found.', 'status' => 400]); + expect($response)->toBe(['apiError' => 'Place resource not found.', 'status' => 404]); })->with(['update', 'find', 'delete']);