我正在使用laravel 5.7,并已在控制器中设计了这样的验证系统,
public function verifyUser($token)
{
$verifyUser = VerifyUser::where('token', $token)->first();
if(isset($verifyUser) ){
$user = $verifyUser->user;
if(!$user->verified) {
$verifyUser->user->verified = 1;
$verifyUser->user->save();
$info = "Your e-mail is verified. You can now login.";
}else{
$info = "Your e-mail is already verified. You can now login.";
}
}else{
return redirect()->back()->with('warning', "Sorry your email cannot be identified.");
}
return redirect()->back()->with('info', $info);
}
}
现在我需要向管理员admin@mybook.net
发送默认电子邮件,以在此方法中对以上系统进行详细说明后进行通知。我该如何处理?
答案 0 :(得分:0)
也许您可以这样编写代码:
public function verifyUser($token)
{
$verifyUser = VerifyUser::where('token', $token)->first();
if(!$verifyUser) {
return redirect()->back()->with('warning', "Sorry your email cannot be identified.");
}
$user = $verifyUser->user;
if($verifyUser->user->verified) {
return redirect()->back()->with('info', 'Your e-mail is already verified. You can now login.');
}
$verifyUser->user->update(['verified' => 1]);
// Send email here.
return redirect()->back()->with('info', 'Your e-mail is verified. You can now login.');
}