I have a registration form with unique email validation. When I enter different character case, emails does not apply unique validation.
example@gmail.com, Example@gmail.com, eXample@gmail.com
: Laravel unique validation is failed.
example@gmail.com, example@gmail.com, example@gmail.com
: Laravel unique validation is success.
Please check my code below and correct me. Email is storing as lowercase in database.
DB - Mongodb,
Framework - Laravel 5.5
jenssegers/laravel-mongodb is using to connect laravel and mongodb
RegisterController.php
protected function validator(array $data)
{
return Validator::make($data, [
'firstName' => 'required|string|max:255',
'lastName' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:user,usrEmail',
'password' => 'required|string|min:6|confirmed',
]);
}
User.php
public function setusrEmailAttribute($value)
{
$this->attributes['usrEmail'] = strtolower($value);
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire