@php $hasChildren = $category->children->where('is_active', true)->count() > 0; $isFolder = $category->isFolder() || $hasChildren; $totalDocs = $category->activeDocuments->count(); // Calculate total documents including children if ($hasChildren) { foreach ($category->children->where('is_active', true) as $child) { $totalDocs += $child->activeDocuments->count(); foreach ($child->children->where('is_active', true) as $grandchild) { $totalDocs += $grandchild->activeDocuments->count(); } } } @endphp
@if($hasChildren)
@foreach($category->children->where('is_active', true)->sortBy('sort_order') as $child) @include('components.category-menu-item', ['category' => $child, 'level' => $level + 1]) @endforeach
@else
{{ $category->name }} @if($category->active_documents_count > 0) {{ $category->active_documents_count }} @endif
@endif