Hi all,
I just starting coding in Laravel. I starting code review Laravel.io sources... I can not understand how User class create by email-adress at account confirmation.
In route we have:
Route::get('email-confirmation/{email_address}/{code}', ['as' => 'email.confirm', 'uses' => 'EmailConfirmationController@confirm']);
In controller:
public function confirm(User $user, string $code) { (...) }
How User param create this Object by email (string)? First param is string.
Many thanks for reply :)
Hey Piotrek,
This is done by route bindings. You can find the file here: routes/bindings.php
.
So basically we tell Laravel to return an instance of a user when it tries to pass the email_address
to the controller. If it doesn't finds an instance it'll throw a 404.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community