Support the ongoing development of →
Requests Architecture Configuration
Last updated 1 year ago.

They are for different purposes.

Route::model is for route model bindings. You can bind a route parameter, user to a model App\User.

Route::model('user', 'App\User');

Route::get('user/{user}', function ($user) {
    // $user is of type App\User

For routes that have the route parameter user, the Model will try to be resolved based on the value of that route parameter. Instead of receiving the parameter value in your controller method you will end up with a User model being passed.

Route::resource is for registering your resource routes for you. You could define your routes explicitly to do the same thing. The router is using the 'name' of the resource as the route parameter name (wildcard).

The way these work together is just based upon what the parameter ends up being in your route definitions. Route::resource('user', 'UserController'); will give you routes with the route parameter {user} in it. Since we bound user to App\User, would resolve a User with id of 1 and bind that to the route.


thank you so much. well explained.


Sign in to participate in this thread!


Your banner here too?

arafatx arafatx Joined 16 Aug 2015


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.