In rules()
method of your Form Request class you'll have to iterate through events
array and set a validator for each element:
public function rules()
{
$rules = [
//your other rules go here
];
$events = $this->input( 'events' );
if ( !empty( $events ) )
{
foreach ( $events as $key => $event ) // add individual rules to each image
{
$rules[ sprintf( 'events.%d', $key ) ] = 'min:2';
}
}
return $rules;
}
Alternatively, you could redefine validator()
method of the same class and use each()
to set rules for each event. I haven't used this particular method, but it should work:
public function validator()
{
$validator = $this->getValidatorInstance($factory);
$validator->each('events', 'min:2');
return $validator;
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community