@php $groupedCategories = $categories->groupBy('parent_id'); $currentCategories = $groupedCategories->get(0); @endphp @if($currentCategories) @foreach ($currentCategories as $category) @php $hasChildren = $groupedCategories->has($category->id); @endphp @if ((!$more && $loop->index < 10) || ($more && $loop->index >= 10))