@php /** * Renders a settings screen from an array, so a page is a definition and * not another copy of this markup. * * Section: ['title', 'icon', 'desc'?, 'items' => []] * Item: ['tipo', 'campo', 'label', 'desc'?, 'options'?, 'largura'?, 'hint'?] * * Types: text, number, textarea, mono, select, switch, checks. * * No values here: the form starts empty behind the skeleton and the API * fills it in. That is what keeps the page fast on a distant server. */ $isRow = fn (array $i) => in_array($i['tipo'], ['switch', 'select'], true) && ! empty($i['desc']); @endphp @foreach($sections as $section)

{{ $section['title'] }}

@if(! empty($section['desc']))

{{ $section['desc'] }}

@endif
@php $groups = []; foreach ($section['items'] as $item) { $modo = $isRow($item) || $item['tipo'] === 'checks' ? 'solto' : 'grade'; $ultimo = array_key_last($groups); if ($ultimo !== null && $groups[$ultimo]['modo'] === $modo && $modo === 'grade') { $groups[$ultimo]['items'][] = $item; continue; } $groups[] = ['modo' => $modo, 'items' => [$item]]; } @endphp @foreach($groups as $group) @if($group['modo'] === 'grade')
@foreach($group['items'] as $item) @include('includes.form-field', ['item' => $item]) @endforeach
@else @foreach($group['items'] as $item) @include('includes.form-field', ['item' => $item]) @endforeach @endif @endforeach
@endforeach