如果注册后的第一个邮件没有发送,我有一个简单的功能,点击即可向用户发送电子邮件。但是当我单击该按钮时,它没有任何反应,而是将我带到主页。
重发函数:
protected function resend()
{
$user = Account::where('email', Auth::user()->email)->first();
$user->verifyToken = Str::random(40);
$user->save();
$this->sendEmail($user);
return redirect(route('verifyEmail'))->with('user',$user)->with('success', 'A link has been sent to your email');
}
Route::post('/resend/email', 'Auth\RegisterController@resend')->name('resendEmail');
html:
<form action=" {!! route('resendEmail') !!}" method="POST">
@csrf
<button class="btn btn-default" type="submit" value="Submit">Resend Verification Link</button>
</form>
通过添加到构造函数修复了中间件问题: $this->middleware('auth', ['except' => ['resendEmail']]);
HUX布斯