fix: trả rows_by_host cho network trong cây vCenter

Network dùng chung giữa các host bị unique('network') giữ lại host đầu tiên.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
baodev0
2026-10-27 10:49:01 +07:00
co-authored by Claude Sonnet 5.5
parent e1ffbf52fe
commit 8108e8fe53
@@ -205,7 +205,8 @@ class VCenterController extends Controller
// Networks — deduplicated at datacenter level // Networks — deduplicated at datacenter level
$dcNetworks = $uniqueHosts $dcNetworks = $uniqueHosts
->flatMap(fn($host) => $host->network ?? collect()) ->flatMap(fn($host) => $host->network ?? collect())
->unique('network') ->groupBy('network')
->map(fn($nets) => $nets->first()->setAttribute('rows_by_host', $nets->pluck('id', 'module_host_id')))
->map(fn($net) => [ ->map(fn($net) => [
'id' => 'network-' . $net->id, 'id' => 'network-' . $net->id,
'name' => $net->name, 'name' => $net->name,
@@ -215,6 +216,7 @@ class VCenterController extends Controller
'network' => $net->network, 'network' => $net->network,
'net_type' => $net->type, 'net_type' => $net->type,
'module_host_id' => $net->module_host_id, 'module_host_id' => $net->module_host_id,
'rows_by_host' => $net->rows_by_host,
'status' => $net->status, 'status' => $net->status,
], ],
]); ]);