@props([ 'categories' => [], 'selected' => [], // array of selected IDs (passed down for highlighting) 'multiple' => false, 'onSelect' => null, // JS callback name, e.g. 'selectCategory' 'depth' => 0, ])
@foreach ($categories as $category) @php $hasChildren = !empty($category->children); $isSelected = in_array($category->id, (array) $selected); @endphp
{{-- Row --}}
id}, '". addslashes($category->name) ."')" : '' }}" @endif > {{-- Left: icon + label --}}
@if ($category->image_url) {{ $category->name }} @else
@endif {{ $category->name }} @if ($hasChildren) {{ count($category->children) }} @endif
{{-- Right: chevron or check --}} @if ($hasChildren) @elseif ($isSelected) @endif
{{-- Children --}} @if ($hasChildren)
@endif
@endforeach