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
$dcNetworks = $uniqueHosts
->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) => [
'id' => 'network-' . $net->id,
'name' => $net->name,
@@ -215,6 +216,7 @@ class VCenterController extends Controller
'network' => $net->network,
'net_type' => $net->type,
'module_host_id' => $net->module_host_id,
'rows_by_host' => $net->rows_by_host,
'status' => $net->status,
],
]);