Tutorial by Examples

Laravel automatically resolves Eloquent models defined in routes or controller actions whose variable names match a route segment name. For example: Route::get('api/users/{user}', function (App\User $user) { return $user->email; }); In this example, since the Eloquent $user variable de...
To register an explicit binding, use the router's model method to specify the class for a given parameter. You should define your explicit model bindings in the boot method of the RouteServiceProvider class public function boot() { parent::boot(); Route::model('user', App\User::class); ...

Page 1 of 1