@props([ 'data' => null, ]) @php $categories = $data['categories'] ?? []; $chunks = collect($categories)->chunk(4); // Unique prefix so multiple instances of this block on the same page // never collide on collapse / modal element IDs. $uid = 'aml_' . substr(md5(json_encode($categories)), 0, 8); @endphp
@foreach ($chunks as $chunkIndex => $chunk) @php // Each card sits in a 25%-wide column (col-3). When a row has fewer // than 4 cards they get centered, so the green connector must shrink // to link only the first and last card centers of that row. $count = $chunk->count(); $inset = (4 - $count) * 12.5 + 12.5; @endphp
@if ($count > 1)
@endif
@foreach ($chunk as $category) @php $catIndex = $chunkIndex * 4 + $loop->index; $collapseId = $uid . '_collapse_' . $catIndex; $listItems = $category['list_items'] ?? []; @endphp
    @foreach ($listItems as $itemIndex => $item) @php $modalId = $uid . '_modal_' . $catIndex . '_' . $itemIndex; @endphp
  • @endforeach
@endforeach
@endforeach
{{-- Modals --}} @foreach ($categories as $catIndex => $category) @foreach (($category['list_items'] ?? []) as $itemIndex => $item) @php $modalId = $uid . '_modal_' . $catIndex . '_' . $itemIndex; @endphp @endforeach @endforeach