@php $depth = (int) ($depth ?? 0); $children = $cat->relationLoaded('children') ? $cat->children : collect(); $hasChildren = $children->isNotEmpty(); $childCount = $hasChildren ? $children->count() : (int) ($cat->children_count ?? 0); $isRoot = $depth === 0; $rowClass = $isRoot ? 'admin-category-tree__row--root' : 'admin-category-tree__row--child'; $canUpdate = auth()->user()->can(\App\Models\Permission::PERMISSION_CATEGORIES_UPDATE); $openDefault = ! empty($expandAll) ? 'true' : 'false'; @endphp