Route Model Binding: Explicit Binding

Public function boot()
{
    parent::boot();

    Route::model('user', App\User::class);
}
Route::get('profile/{user}', function (App\User $user) {
    //
});

To register an explicit binding, use the router's model method to specify the class for a given parameter.

Customizing The Resolution Logic

Public function boot()
{
    parent::boot();

    Route::bind('user', function ($value) {
        return App\User::where('name', $value)->first() ?? abort(404);
    });
}

If you wish to use your own resolution logic, you may use the Route::bind method.

Route Model Binding: Explicit Binding — Structure map

Clickable & Draggable!

Route Model Binding: Explicit Binding — Related pages: