I have a question in Laravel. How can I make a single validation rule in Laravel that meets two conditions? The logic would be like this in the database:
"users.document_usu is unique and users.rol_usu=2"
How could I modify this rule so that it does the same "unique:users,document_usu"
thank you very much for your attention.
>Solution :
You can use Rule class
'document_usu' => ['required', Rule::unique('users')->where(function ($query) use ($request) {
return $query->where('rol_usu', 2);
})],