@php $max = !empty($max) ? $max: 20; $current = (int) Arr::get($attributes, 'quantity') ?: 6; $selector = 'quantity_' . Str::random(20); $choices = collect()->times($max)->mapWithKeys(function($i) {return [$i => $i];}); @endphp
{!! Form::customSelect('quantity', $choices, $current, ['id' => $selector, 'data-max' => $max]) !!}
@for ($i = 1; $i <= $max; $i++)

@foreach ($fields as $k => $field) @php $key = $k . '_' . $i; $name = $i <= $current ? $key : ''; @endphp
@switch(Arr::get($field, 'type')) @case('image') {!! Form::mediaImage($name, Arr::get($attributes, $key), ['data-name' => $key]) !!} @break @case('color') {!! Form::customColor($name, Arr::get($attributes, $key), ['data-name' => $key]) !!} @break @case('icon') {!! Form::themeIcon($name, Arr::get($attributes, $key), ['data-name' => $key]) !!} @break @case('number') {!! Form::number($name, Arr::get($attributes, $key), [ 'class' => 'form-control', 'placeholder' => Arr::get($field, 'placeholder', Arr::get($field, 'title')), 'data-name' => $key, ]) !!} @break @case('percentage') {!! Form::number($name, Arr::get($attributes, $key), [ 'class' => 'form-control', 'placeholder' => Arr::get($field, 'placeholder', Arr::get($field, 'title')), 'data-name' => $key, 'min' => 0, 'max' => 100, ]) !!} @break @case('textarea') {!! Form::textarea($name, Arr::get($attributes, $key), [ 'class' => 'form-control', 'placeholder' => Arr::get($field, 'placeholder', Arr::get($field, 'title')), 'data-name' => $key, 'rows' => 3, ]) !!} @break @case('checkbox') {!! Form::customSelect($name, ['no' => __('No'), 'yes' => __('Yes')], Arr::get($attributes, $key), ['data-name' => $key]) !!} @break @default {!! Form::text($name, Arr::get($attributes, $key), [ 'class' => 'form-control', 'placeholder' => Arr::get($field, 'placeholder', Arr::get($field, 'title')), 'data-name' => $key, ]) !!} @endswitch
@endforeach
@endfor