I have an array with data (events) and a table event_user table
Now I want that if the events are sold out, they will be put on a waiting list. The idea was to add queue pivot, and flag it whit a boolean when the available tickets are sold out. Therefore i have to make a calculation event->total_ticket - the subscribers. Got that part covered.
But honestly I have no idea where/how to start with adding stuff to a collection. Anyone have any suggestions or ideas?
If your events model has the number of tickets available, you can use the belongsToMany(‘event_users’) relationship. You can use Event/Listeners to check for ticket availability by comparing the count of records in event_users to the number of tickets for the event. I would consider adding a method to your events table to get the available number of tickets. ->getTicketAvailability