任何人都可以对此有所了解吗?
我已经为密码重置定义了自定义路由,它有一个路由参数
Route::post('{school}/password/email', 'Web\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
Route::get('{school}/password/reset', 'Web\ForgotPasswordController@showLinkRequestForm')->name('password.request');
Route::post('{school}/password/reset', 'Web\ResetPasswordController@reset')->name('password.reset.submit');
Route::get('{school}/password/reset/{token?}', 'Web\ResetPasswordController@showResetForm')->name('password.reset');
想知道如何将school
路由参数传递到我的用户模型中的sendPasswordResetNotification
,其中我已指定密码重置的自定义通知
public function sendPasswordResetNotification($token)
{
$school = ''; //How do I access the school route parameter in here? Is there a way to pass the route parameter to the sendPasswordResetNotification function?
$this->notify(new SchooUserPasswordResetNotification($token, $school));
}
任何帮助都将深受赞赏。
答案 0 :(得分:1)
您可以通过request
辅助方法访问它,例如:
request()->route()->parameter('school')
示例:
public function sendPasswordResetNotification($token)
{
$school = request()->route()->parameter('school');
$this->notify(new SchooUserPasswordResetNotification($token, $school));
}