Php 重新发送电子邮件的功能将我带到主页,并且在给定的函数-Laravel中不做任何操作
我有这个简单的功能,点击发送电子邮件给用户,如果第一个注册后没有去。但是当我点击这个按钮时,它什么也不做,把我带到主页 重发功能:Php 重新发送电子邮件的功能将我带到主页,并且在给定的函数-Laravel中不做任何操作,php,laravel,authentication,Php,Laravel,Authentication,我有这个简单的功能,点击发送电子邮件给用户,如果第一个注册后没有去。但是当我点击这个按钮时,它什么也不做,把我带到主页 重发功能: protected function resend() { $user = Account::where('email', Auth::user()->email)->first(); $user->verifyToken = Str::random(40); $user->save()
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');
}
<form action=" {!! route('resendEmail') !!}" method="POST">
@csrf
<button class="btn btn-default" type="submit" value="Submit">Resend Verification Link</button>
</form>
Route::post('/ressend/email','Auth\RegisterController@resend')->name('resendEmail')代码>
html:
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');
}
<form action=" {!! route('resendEmail') !!}" method="POST">
@csrf
<button class="btn btn-default" type="submit" value="Submit">Resend Verification Link</button>
</form>
@csrf
重新发送验证链接
通过添加到构造函数解决了中间件问题:
$this->中间件('auth',['except'=>['resendEmail']])代码>将此添加到注册表控制器上
\u构造方法:
可能是因为在路由中重新发送之前的前导/
?尝试Route::post('ressend/email'),…
但是return redirect(Route('verifyEmail'))->with('user',$user)->with('success','A link has sent to your email');
不应该返回到给定的路由吗?它可能不会影响函数。您可以在函数中添加一些内容来确认。嗯,是的,dd没有显示给我们。