1) id="cat-{{ $parentId }}" @endif> @foreach ($categories as $category) @php // Unique collapse id $collapseId = 'cat-' . $category->id; // Total products including children $totalCount = $category->products->count(); foreach ($category->children as $child) { $totalCount += $child->totalProducts(); } @endphp
  • {{ $category->name }} ({{ $totalCount }}) @if ($category->children->count()) @endif
    {{-- Children --}} @if ($category->children->count()) @include('pages.product.category-tree', [ 'categories' => $category->children, 'level' => $level + 1, 'parentId' => $category->id ]) @endif
  • @endforeach