我想检查用户提供的电子邮件是否有效。为了做到这一点,我修改了寄存器用户文件的寄存器方法。这是我的代码
public function register(Request $request)
{
$this->validator($request->all())->validate();
Mail::to($request->email)->send(new RegistrationConfirmationMail($request->email));
if( count(Mail::failures()) > 0 ) {
return redirect('/register')
->withInput($request->only('email','name','address','district','gender','mobile'))
->withErrors(['invalid_email', 'Your email does not exist. Provide another email']);
}
event(new Registered($user = $this->create($request->all())));
$this->registered($user);
$this->guard()->login($user);
return $this->registered($request, $user)
?: redirect($this->redirectPath());
}
但是这段代码没有将我重定向到注册页面,而是注册用户并登录了他。怎么解决这个?