favoriteRooms()->whereKey($room->id)->exists(); $room->load([ 'players' => fn ($query) => $query ->active() ->select(['id', 'room_id', 'user_id', 'name', 'is_moderator', 'created_at']) ->orderByDesc('is_moderator') ->orderBy('created_at'), 'players.votes' => fn ($query) => $query ->where('room_id', $room->id) ->where('round', $room->current_round), ]); $currentVote = $room->players ->firstWhere('id', $currentPlayer->id) ?->votes ->first() ?->value; return new RoomPageData( room: $room, currentPlayer: $currentPlayer, isFavorite: $isFavorite, currentVote: $currentVote, statistics: $this->statistics->currentRound($room), ); } }