I am trying to validate to make sure no two users with same email ever register twice (meaning only users with unique email address can register).
this is my code in Register Controller
protected function validator(array $data)
{
return Validator::make($data, [
'firstname' => 'required|max:255',
'lastname' => 'required|max:255',
'email' => 'required|max:255|unique:users',
'password' => 'required|min:6|confirmed',
]);
}
Here, I say email unique:users.
but when I register new user for the first time and re-register the same user with all different info but same email address. I get this error:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'test@gmail.com' for key 'users_email_unique' (SQL: insert into `users` (...))
I know its a duplicate entry but I want to redirect user to register page and tell that user already exists with this email. How do I do that?
I tried adding Redirect to the validator function, tried to create my own validator in create function but no luck.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2rcLJ95
via IFTTT
Aucun commentaire:
Enregistrer un commentaire