How to add laravel multiple required_if (like AND Logical) at Laravel Validation. I want to required 'featured_img' if (pagetype == '2' and featured == '1')
I try this one :
'featured_img' => 'required_if:pagetype,2|required_if:featured,1|mimes:jpg,jpeg,bmp,png',
but this validation make 'featured_img' required though one of them false (it is like logical "OR". i want make it like "AND" logical)
Thanks
You can use custom validation like :
$validator->sometimes('featured_img', 'required', function($request) {
return ($request->pagetype == '2' && $request->featured == '1')
});
Take a look at Conditionally Adding Rules.
Hope this will help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With