A
A
Alexander Shapoval2017-10-15 10:48:56
Laravel
Alexander Shapoval, 2017-10-15 10:48:56

Why is the route binding to the model not returning 404?

In the route specified

Route::get('/{user}/profile/edit/', [
    'as' => 'profile-edit',
    'uses' => '[email protected]'
])->middleware('auth');

In the service If I pass the user ID that is in the database, everything works fine, and if there is no user, instead of a 404 error I get the error Sorry, the page you are looking for could not be found. 2/2 NotFoundHttpException in Handler.php line 113: No query results for model [App\User]. Laravel 5.5 Same with this route
Route::model('user', \App\User::class);


Route::get('/{user}/profile/edit/', function (\App\User $user) {
    return $user->email;
});

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Victor, 2017-10-15
@sanek_os9

Create errors/404.blade.php and it will be displayed

A
Arman, 2017-10-15
@Arik

So isn't it a 404 (NotFoundHttpException)? There will be no messages for production

A
Alexander Pushkarev, 2017-10-15
@AXP-dev

Do you have debug enabled in your env file?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question