@php $groupedCategories = $categories->groupBy('parent_id'); $currentCategories = $groupedCategories->get(0); @endphp @if($currentCategories) @foreach ($currentCategories as $category) @php $hasChildren = $groupedCategories->has($category->id); @endphp
  • $hasChildren])> @if ($categoryImage = $category->icon_image) {{ $category->name }} @elseif ($categoryIcon = $category->icon) @endif {{ $category->name }} @if($hasChildren && $currentCategories = $groupedCategories->get($category->id)) @endif
  • @endforeach @endif