@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 $hasChildren, 'admin-category-tree__row--leaf' => ! $hasChildren, 'admin-category-tree__row--clickable' => $hasChildren, ]) @if ($hasChildren) @click="if (!$event.target.closest('a, button, form, input, select, textarea')) open = !open" role="button" tabindex="0" @keydown.enter.prevent="open = !open" @keydown.space.prevent="open = !open" :aria-expanded="open.toString()" @endif > @if ($hasChildren) @else @endif {{ $cat->id }} @php($imageUrl = $cat->image ? site_media_url($cat->image) : null) @if ($imageUrl) @else @endif
{{ $cat->name_fa }} @if ($childCount > 0) {{ __('admin.category_children_count', ['count' => $childCount]) }} @endif
{{ $cat->slug }} @if ($hasChildren)
@foreach ($children as $child) @include('admin.categories.partials.row', [ 'cat' => $child, 'depth' => $depth + 1, 'expandAll' => $expandAll ?? false, ]) @endforeach
@endif