調整Array 用 roomName 當 key

This commit is contained in:
allen.yan 2025-06-04 15:23:02 +08:00
parent f7f8dad5b4
commit 69e12a08bf

View File

@ -58,13 +58,15 @@ class BranchControlController extends Controller
'enable' => $branch->enable,
'rooms' => $branch->rooms
->filter(fn($room) => $room->type === RoomType::PC)
->map(function ($room) {
->mapWithKeys(function ($room) {
$roomName = $room->type->value . $room->name;
return [
'room_name' => $room->type->value.$room->name,
'is_online' => $room->is_online,
'status' => $room->status->value,
'started_at' => $room->started_at,
'ended_at' => $room->ended_at,
$roomName => [
'is_online' => $room->is_online,
'status' => $room->status->value,
'started_at' => $room->started_at,
'ended_at' => $room->ended_at,
]
];
}),
];