file request api update

This commit is contained in:
Čarodej
2022-05-04 09:03:18 +02:00
parent cf7e17e188
commit 67b9f7f4dc
3 changed files with 31 additions and 8 deletions
+9 -1
View File
@@ -50,8 +50,16 @@ class Handler extends ExceptionHandler
public function render($request, Throwable $exception)
{
if ($exception instanceof ModelNotFoundException) {
if (in_array('application/json', $request->getAcceptableContentTypes())) {
return response()->json([
'type' => 'error',
'message' => "We couldn't find your requested item.",
], 404);
}
return response()
->redirectTo('/not-found')->setStatusCode(404);
->redirectTo('/not-found')
->setStatusCode(404);
}
return parent::render($request, $exception);