You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes you may wish to throw an exception if a model is not found. This is particularly useful in routes or controllers. The findOrFail and firstOrFail methods will retrieve the first result of the query; however, if no result is found, a Illuminate\Database\Eloquent\ModelNotFoundException will be thrown:
If the exception is not caught, a 404 HTTP response is automatically sent back to the user. It is not necessary to write explicit checks to return 404 responses when using these methods:
Route::get('/api/flights/{id}', function ($id) {
returnApp\Flight::findOrFail($id);
});
It would be nice if we had the equivalent findByUuidOrFail method.
The text was updated successfully, but these errors were encountered:
majidalaeinia
changed the title
Implementing findByUuidOrFail
Implementing findByUuidOrFail method
Jun 18, 2019
majidalaeinia
changed the title
Implementing findByUuidOrFail method
Implementing 'findByUuidOrFail' method
Jun 18, 2019
As you might have read on Laravel Documentation:
It would be nice if we had the equivalent
findByUuidOrFail
method.The text was updated successfully, but these errors were encountered: