I've seen the following route:
Route::prefix('/users/{user}')->group(function () {
Route::get('groups/{group}', 'UserGroupController@show');
}
And in UserGroupController:
use App\Group;
public function show(Request $request, User $user, Group $group)
{
dd($group);
}
My question is how does the $group
model object gets constructed here from a raw route parameter string?
My guess is laravel's service container does the following magic (maybe sth like
- Injecting the Group model,
- then do sth like
Group::where('id', $group)->first()
but unsure about this.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire