@php
$children = $gruppo->children()->with(['diocesi', 'individui'])->orderBy('nome')->get();
$hasChildren = $children->count() > 0;
$canWriteGruppi = Auth::user()->canManage('gruppi');
$responsabili = $gruppo->getResponsabili();
@endphp
@if($hasChildren)
@else
@endif
{{ $gruppo->nome }}
{{ $gruppo->depth ?? 0 }}
{{ $gruppo->diocesi?->nome ?? '' }}
@if($responsabili->count() > 0)
· {{ $responsabili->pluck('cognome')->implode(', ') }}
@endif
@if($gruppo->individui_count > 0)
{{ $gruppo->individui_count }} membri
@endif
@if($hasChildren)
{{ $children->count() }} figli
@endif
@if($canWriteGruppi)
@php
$isParent = $hasChildren;
$isSuperAdmin = Auth::user()->isSuperAdmin();
$canDelete = !$isParent || $isSuperAdmin;
@endphp
@if($canDelete)
@else
@endif
@endif
@if($hasChildren)
@foreach($children as $child)
@include('gruppi.partials.tree-item', ['gruppo' => $child])
@endforeach
@endif