My model TicketBuyer columns include ticket_buyer name and number_of_tickets purchased. I want to randomly select a winning ticket. I think my preference is to create another model (SelectTable) that has the ticket_buyer name replicated over the number of rows equal to the number_of_tickets purchased, thereby giving equal weight to each record. I can then just run a simple sort and pick the first record in the new table. I am having trouble auto creating the table with the correct number of rows for each ticket_buyer. Of course, there may be a more eloquent/ efficient way to do this as well. Advice is much appreciated.
Aucun commentaire:
Enregistrer un commentaire