Skip to content

Commit f65d35e

Browse files
authored
[Bugfix] fix response when a latest result is not found (alexjustesen#472)
1 parent bd64a2a commit f65d35e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

app/Http/Controllers/API/Speedtest/GetLatestController.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ public function __invoke()
1616
{
1717
$latest = Result::query()
1818
->latest()
19-
->firstOr(function () {
20-
return response()->json([
21-
'message' => 'No results found.',
22-
], 404);
23-
});
19+
->first();
20+
21+
if (! $latest) {
22+
return response()->json([
23+
'message' => 'No results found.',
24+
], 404);
25+
}
2426

2527
return response()->json([
2628
'message' => 'ok',

0 commit comments

Comments
 (0)