@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