ssquare
4 months ago

How to handle reoccuring events

Posted 4 months ago by ssquare

I am trying to make booking system something like booking futsal ground. Here, the user can select the time and date and make the book for it, and they can also check for repetition like, daily, weekly, monthly until xx date. This means there will be end-date predefined.

I have searched quite for a few time as some of them are quite complex or some of them are incomplete. What do you recommend to handle such tasks?

Or, if there is any package which handles all of the tasks let me know. Later, I will be integrating with a full calendar, so please consider from that frontend point of view as well.

Update:

So far I have come to the following model after quite some searching:

Events_repeat
--------------------
id
repeat_interval    `1 = daily, 2 = weekly, 3 = monthly`
repeat_date       `this is exactly the date something like 14th of every month`
ordinal        `1 = first, 2 = second, 3 = third, 4 =fourth, 5 = last`
week_days      `1 =  Sunday, 2 =  Monday,  4 = Tuesday, 8 = Wed, 16 = Thu, 32 = Fri, 64 = Sat`
start_date    `start date`
end_date    `end_date`
event_id        `foreign key`

So some examples:

*If occurs daily *

id
1 //daily
0
0
0
2019-05-17
2019-07-17

If occurs weekly

id
2 //weekly
0
0
65   //sun + sat i.e 1+32=33
2019-05-17
2019-07-17

If occurs monthly at 15th of each month

id
3 //monthly
15
0
0
2019-05-17
2019-07-17

If occurs monthly at third Friday of each month

id
3 //monthly
0
3  //third
32  //Friday
2019-05-17
2019-07-17

So, far I am convinced about storing strategy, but I am not convinced yet with its selecting strategy. I could not figure out it yet. How can fetch all the events that are going to happen in a particular month lets say at june of 2019

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