{{-- صف واحد في شجرة الحسابات + أبناءه (recursive) --}} @foreach (($byParent[$pid] ?? []) as $a) @php $kids = $byParent[$a->id] ?? []; $hasK = count($kids) > 0; [$d, $c] = $totals[$a->id] ?? [0, 0]; $net = round($d - $c, 2); $tId = $rootType ?? $a->account_type; $tColor = $typeColors[$tId] ?? '#475569'; $tName = isset($types[$a->account_type]) ? ($ar ? $types[$a->account_type]->name_ar : ($types[$a->account_type]->name_en ?: $types[$a->account_type]->name_ar)) : ''; $isFolder = $hasK || $a->is_parent; @endphp