Query Help

Posted 2 months ago by movepixels

I need some assistance as how to get a list of available dates. Try to explain what I need so hope this comes across clear. I build an array of the next 10 weeks (Sun thru Sat) that will get be used as a select input of dates to select from. Now each date(week) has a limit of 25 spots so I have a pivot table of event_user which holds the event_id, user_id, date, (other fields not relevant) So i need to build a query that works with each of the dates so if that date has 25 spots it gets a disabled property so any user can't select that date, but still shows in the select options.

I could loop thru each date key from the array and manually if count < 25 do something else type setup but hoping there was a cleaner way.

Current date array looks like:

0: ["January 6th 2019 to January 12th 2019"]
1: ["January 13th 2019 to January 19th 2019"]
2: ["January 20th 2019 to January 26th 2019"]
3: ["January 27th 2019 to February 2nd 2019"]
4: ["February 3rd 2019 to February 9th 2019"]
5: ["February 10th 2019 to February 16th 2019"]
6: ["February 17th 2019 to February 23rd 2019"]
7: ["February 24th 2019 to March 2nd 2019"]
8: ["March 3rd 2019 to March 9th 2019"]
9: ["March 10th 2019 to March 16th 2019"]
10: ["March 17th 2019 to March 23rd 2019"]

So I eventually need a way to know if any of these dates has 25 users for this event in the event_user table, if so I need to add a 'disabled' => true to that date key.

Any insight, help, ideas will be greatly appreciated. Thanks!

Dave

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.