mardi 7 août 2018

Error when trying to redirect after user creation

Sample code:

protected function create(array $data)
{
  User::create([
    'name' => $data['name'],
    'email' => $data['email'],
    'password' => Hash::make($data['password']),
  ]);

  // redirect to login page with message
  return redirect('/login');

}

I'm trying to do a redirect immediately after user creation in the RegisterController.php controller in order to prevent login when a new user is created. However, I get the error below:

Error message:
Type error: Argument 1 passed to Illuminate\Auth\SessionGuard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable

How can I intercept this request to prevent it from being passed to the next request and instead redirect with a message?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire