I have one form where I have 5 text fields and 2 input type file fields. for all 7 fields, I have written custom validation rules in laravel and I want all field required if a type is a business so I used required_if in all fields, for text field it's working but for an image (input type file) it's not working it always consider as file present in request and not give any error if file not uploaded when I changed it to required than it only gives me error for input type file.
public function rules()
{
return [
'country' => 'required_if:type,business',
'country2' => 'required_if:type,business',
'company' => 'required_if:type,business',
'number' => 'required_if:type,business',
'expiry' => 'required_if:type,business',
'profile_pic' => 'required_if:type,business | mimes:jpeg,jpg,png,pdf',
'document_pic' => 'required_if:type,business | mimes:jpeg,jpg,png,pdf',
];
}
'required_if:type,business | image'
– Exterminator