I am trying to add more users with the same email in the database disabling the unique for email, adding another column for that [account]...
The registration form also includes this field,
<input type="text" name="account" required hidden value="{{getUUid()}}"/>
@if ($errors->has('account'))
<span class="help-block">
<strong>{{ $errors->first('account') }}</strong>
</span>
@endif
and all is stored correctly in the database, with multiple users with same email. The problem I am facing is related to the validation; changed RegisterController.php to
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255',
'password' => 'required|string|min:6|confirmed',
'account' => 'required|unique:users|max:50',
]);
}
and create function to
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
'account' => (getEvent()->hash.'_'.$data['email']),
]);
}
when actually there is a duplicate I am having an error 500 with the database error
Illuminate \ Database \ QueryException (23000)
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry for key 'users_account_unique'
I am new to Laravel and don't understand what else I am missing to perform the same behavior of the email validation and prevent the database error.
* Solved * with a middleware redirecting to register if the user already exists.