Refactor domain grouping in domains API controller

This commit is contained in:
Andras Bacsai 2024-03-07 11:25:15 +01:00
parent 7a21312daf
commit 5e2afd4b4d

View File

@ -48,7 +48,12 @@ public function domains(Request $request)
}
$domains = $domains->groupBy('ip')->map(function ($domain) {
return $domain->pluck('domain')->flatten();
});
})->map(function ($domain, $ip) {
return [
'ip' => $ip,
'domains' => $domain,
];
})->values();
return response()->json($domains);
}