Skip to content

Commit b5d79ad

Browse files
authored
Merge pull request #687 from hhaccessibility/issue-168
app: adjusted the API for getting the ratable location to return 404 …
2 parents c464555 + e80e944 commit b5d79ad

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

app/app/Http/Controllers/PWAController.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ public function getNearbyLocationToRate(float $longitude, float $latitude)
5151
foreach ($search_results as $search_result) {
5252
$locations []= $search_result;
5353
}
54-
55-
if (empty($locations)) {
56-
return response()->json([
54+
$not_found_response = response()->json([
5755
'message' => 'No location found close enough.'
5856
], 404);
57+
58+
if (empty($locations)) {
59+
return $not_found_response;
5960
}
6061
\App\Libraries\Gis::updateDistancesFromPoint($longitude, $latitude, $locations);
6162
$location = $locations[0];
@@ -64,6 +65,10 @@ public function getNearbyLocationToRate(float $longitude, float $latitude)
6465
$location = $location_;
6566
}
6667
}
68+
if ($location->getNumberOfUsersWhoRated() > 0) {
69+
return $not_found_response;
70+
}
71+
6772
return response()->json([
6873
'name' => $location->name,
6974
'id' => $location->id

0 commit comments

Comments
 (0)