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