Reputation: 1
Laravel has renderable exceptions that it renders by default if they were thrown (like ModelNotFoundException, AuthenticationException, ValidationException). Is there a way to prevent this default behavior?
example: if I use the Model::findOrFail($someId)
method and there is no model with id $someId
, then laravel will show 404 page (because findOrFail
method threw a ModelNotFoundException exception). But I need Laravel to process it as a normal, non-renderable exception.
Upvotes: 0
Views: 257
Reputation: 580
Use find
instead of findOrFail
:
$model = Model::find($someId);
if ($model) {
// the model was found
} else {
// the model was not found
}
// do other stuff here
Upvotes: 1