From 69e12a08bf2a2693260325c19cbc786910843f5c Mon Sep 17 00:00:00 2001 From: "allen.yan" Date: Wed, 4 Jun 2025 15:23:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AA=BF=E6=95=B4Array=20=E7=94=A8=20roomName?= =?UTF-8?q?=20=E7=95=B6=20key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/BranchControlController.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/BranchControlController.php b/app/Http/Controllers/BranchControlController.php index 15871dc..9ee59de 100644 --- a/app/Http/Controllers/BranchControlController.php +++ b/app/Http/Controllers/BranchControlController.php @@ -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, + ] ]; }), ];