Answer the question
In order to leave comments, you need to log in
Is it possible to somehow remake firstOrFail?
Is it possible to somehow remake the firstOrFail error when using the API?
I created a controller that has this very method, and if not found, a huge standard error is simply thrown:
[{
"message": "No query results for model [App\\Models\\User\\Confirmation].",
"exception": "Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException",
"file": "/Users/.../vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php",
"line": 199,
"trace": [
....
{status: 404, errors: [{'Not found': 'Model was not found'}]}
Exceptions/Handler
, but then this error will also be issued in the normal (non-API) version. authorize
and rules
create an additional method, and just do it in the controller. I do $request->execute();
FormRequest
, but I created an additional ApiFormRequest
one, in which I just managed to redo the errors failedAuthorization
and failedValidation
firstOrFail
can’t redo it right there, but maybe there is a place where you can do it right?
Answer the question
In order to leave comments, you need to log in
It is better to do through Exceptions/Handler.
Since you have debug mode enabled, you will get a full error, and in disabled mode - then a 404 page.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question