'How to create an infinite lotto system in solidity

I'm trying to create a Lotto where the owner can generate as many Lottos as they want. To do this I have used a struct and a mapping to hold all the Lotto. But I want to make a function where people can enter the Lotto of their choice (with the id).

Here is my code for the moment (there is no code for the 'enter' function because I can't do it) :

struct Lottos {
    uint maxPlayers;
    string winObject;
    address depositAddress;
    string name;
    uint id;
    bool ended;
}

mapping(uint => Lottos) lottos;
address payable[] public players;
mapping(address => uint balance);
uint public price;

function createLotto(uint _id, string _name, address _depositAddress, string _winObject, uint _maxPlayers, bool _ended) public onlyOwner {
    Lottos memory newLotto = Lottos(_maxPlayers, _winObject, _depositAddress, _name, _id, _ended);
    lottos.push(newLotto);
}


function totalLottos() public view returns (uint) {
    return lottos.length;
}

function checkLotto(uint i) public view returns (uint, string, address, string, uint, bool {
    return (lottos[i].maxPlayers, lottos[i].winObject, lottos[i].depositAddress, lottos[i].name, lottos[i].id, lottos[i].ended);
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source