HI, I am building an AirBnb like app and I am facing an issue with booking validation: I want the user to be able to book in a site only if there is still some space left in this site.
My database looks like this:
- info about the site, amongst them “capacity”
- bookings, 1-to-many relationship to a Booking, ie one site can have several bookings
- date from/to
How can I make sure that for each day of a new booking, the count of booking is lower than the capacity?
Eventually I would also like to be able to count bookings per day to display filling per day.