Is there a way of referencing another field when specifying the exists validation rule in Laravel?
My request :
public function rules()
{
return [
'numero_de_somme' => 'unique:personnels,numero_de_somme|exists:fonctionnaire,num_somme',
'cin' => 'unique:personnels,cin|exists:fonctionnaire,cin',
];
}
in my validation rules I want to be able to make sure that:
num_somme
exists within thefonctionnaire
tablecin
exists within the fonctionnaire table andcin
input must be on the same row of thenum_somme
num_somme : 12345 cin : s89745
num_somme : 78945 cin : U10125
Explaining : for example
- 1st scenario if the input
num_somme
= 12345 andcin
= U10125 the validation must fail - 2nd scenario if the input
num_somme
= 12345 andcin
= s89745 the validation must success
I hope this makes sense.
Thank you