@php $level = (int) ($level ?? 0); $categoryId = (int) ($node->id ?? 0); $categoryName = $node->local->name ?? ''; $children = $node->children ?? collect(); $hasChildren = $children->isNotEmpty(); $isActive = ($activeCategoryId ?? null) !== null && (int) $activeCategoryId === $categoryId; $isExpanded = in_array($categoryId, $expandedCategoryIds ?? [], true); @endphp
  • @if ($hasChildren)
    @if ($isExpanded) @endif @else {{ $categoryName }} @endif