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.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/ORniDL4
via IFTTT
Aucun commentaire:
Enregistrer un commentaire