get()->map(function ($branch) { return [ 'id' => $branch->id, 'branch_name' => $branch->name, 'enable' => $branch->enable, 'rooms' => $branch->rooms->map(function ($room) { return [ 'room_name' => $room->type.$room->name, 'is_online' => $room->is_online, 'status' => $room->status, 'started_at' => $room->started_at, 'ended_at' => $room->ended_at, ]; }), ]; }); return ApiResponse::success(['branches' => $branches]); } }