laravel validation if other field exists code example
Example 1: laravel required if another field has value
'last_name' => 'required_if:another_field,value'
Example 2: laravel required_if fileld has value
'image' => 'required_if:old_image'
Example 3: laravel form validation based on another field value
$validator = Validator::make($request->all(),[
'program' => 'required',
'music_instrument' => 'required_if:program.*,in:Music'
]);
Example 4: laravel required_if fileld has value
'image' => 'required_without:old_image'