*/ public function toArray(Request $request): array { return [ 'id' => $this->resource->id, 'title' => $this->resource->title, 'join_code' => $this->resource->join_code, 'current_round' => $this->resource->current_round, 'players_count' => $this->resource->players_count, 'active_player_count' => $this->resource->active_player_count, 'players' => $this->resource->relationLoaded('activePlayers') ? $this->resource->activePlayers ->map(fn ($player): array => [ 'id' => $player->id, 'name' => $player->name, 'is_moderator' => $player->is_moderator, 'is_owner' => $player->user_id === $this->resource->owner_id, ]) ->values() ->all() : [], 'last_activity_at' => $this->resource->last_activity_at?->toIso8601String(), 'closed_at' => $this->resource->closed_at?->toIso8601String(), ]; } }