I'm making a user CRUD and I use Requests to validate the methods of my controllers. In my update method I have a validator with the following rules:
return [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', function($attribute, $value){
// How to validate?
}],
'roles' => ['required', 'array', 'in:admin,manager,employee,client']
]
I'm trying to validate, when updating a user if there is another user with the same e-mail, but I couldn't find a way to do that.
This is the model I receive (it's a rest api). The user ID comes in as a URL parameter:
{
"name":"Andre Luiz",
"email": "andredx@xxxxxxxx.com",
"roles": ["admin"]
}
How can I do this validation?