I have a users table and two columns that are: email
and phone
.
In my register and login controller, I wanna make a field unique in both email and phone columns.
$data = request()->validate([
'login' => ['required', 'string', 'email', 'max:255', 'unique:users,email'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
This is my code and it only checks email column to ensure the value of login field doesn't exist there. How can I change this rule to check both email and phone columns?
Just make another rule:
$data = request()->validate([
'login' => ['required', 'string', 'email', 'max:255', 'unique:users,email','unique:users,phone'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);