";
echo "| " . $i++ . " | ";
echo "{$indent}{$prefix} {$boldOpen} {$device->global_device_id}{$boldClose} | ";
echo "{$device->installed_on} | ";
echo "" . ($device->dmdt_bidirectional_device ? 'Gross Meter' : 'Net Meter') . " | ";
echo "" . ($device->dmdt_phase) . " Phase | ";
echo "" . ($device->category) . " | ";
echo "
";
if ($device->children && $device->children->count()) {
// 1. Show connections first (with deep indent)
foreach ($device->children->where('installed_on', 'connection') as $child) {
renderDeviceRow($child, $level, ''); // fixed level for all connections
}
// 2. Then poles and other devices (recursive)
foreach ($device->children->where('installed_on', '!=', 'connection') as $child) {
renderDeviceRow($child, $level + 1, '↳');
}
}
}
@endphp
@foreach ($devices as $device)
@php renderDeviceRow($device); @endphp
@endforeach