{{-- Partial for complex table with multi-level headers (rowspan & colspan) Usage: @include('partials.print._print-table-complex', [ 'headers' => [ [ 'label' => 'Buyer Code', 'rowspan' => 2, ], [ 'label' => 'Stok Bulan Lalu', 'colspan' => 2, 'sub' => ['PR', 'KG'] ], ] ]) --}} {{-- Header Row 1 - Main Groups --}} @foreach ($headers as $header) @endforeach {{-- Header Row 2 - Sub Columns (if exists) --}} @php $hasSub = collect($headers)->filter(fn($h) => isset($h['sub']))->count() > 0; @endphp @if ($hasSub) @foreach ($headers as $header) @if (isset($header['sub'])) @foreach ($header['sub'] as $subLabel) @endforeach @endif @endforeach @endif
{{ $header['label'] }}
{{ $subLabel }}