@php $appCode = $node->application?->code; $badgeClass = $appCode === 'ActiveDirectory' ? 'group-ad' : ($appCode === 'Microsoft365' ? 'group-m365' : ''); $isLeaf = in_array($node->id, $leafIds); $hasChildren = false; $children = collect(); foreach ($paths as $pid => $chain) { $ids = collect($chain)->pluck('id')->toArray(); $idx = array_search($node->id, $ids); if ($idx !== false && isset($chain[$idx + 1])) { $child = $chain[$idx + 1]; if (!$children->contains('id', $child->id)) { $children->push($child); $hasChildren = true; } } } @endphp
@if($hasChildren) @else @endif {{ $node->nom }} @if($badgeClass) {{ $appCode === 'ActiveDirectory' ? 'AD' : 'M365' }} @endif @if(!$isLeaf && $hasChildren) ({{ $children->count() }}) @endif
@if($hasChildren)
@foreach($children as $child) @include('modules.annuaire.personnes._groupe_tree', ['node' => $child, 'paths' => $paths, 'leafIds' => $leafIds, 'depth' => $depth + 1]) @endforeach
@endif