I have linked your other post here since I feel they are somewhat related.
The difficulty for your use-case is the way you store your availability and reservation schedule. Yes it is very nice to define time schedules with from/till but storing it likewise make it hard. In those circumstances, I do not use this time of model. I first determine the granularity of the available resources. In your case it looks like it is time slots of 15 minutes as seen here:
I give the UI the possibility to define availability like you do,
but what I store is an array of 8 entries, one for each 15 minutes time slots like:
slots : [
{ time: 09:00 , booked : null }
{ time : 09:15 , booked : null }
{ time : 09:30 , booked : null }
{ time : 09:45 , booked : null }
{ time : 11:00 , booked : null }
{ time : 11:15 , booked : null }
{ time : 11:30 , booked : null }
{ time : 11:45 , booked : null }
]
When a booking comes I simply update the booked field with the appropriate booking_id. It is now trivial to find what is booked and what is not booked. For example a reservation for the given resource from 9:15 to 9:45 would result in:
slots : [
{ time : 09:00 , booked : null }
{ time : 09:15 , booked : booking_id_369 }
{ time : 09:30 , booked : booking_id_369 }
{ time : 09:45 , booked : booking_id_369 }
{ time : 11:00 , booked : null }
{ time : 11:15 , booked : null }
{ time : 11:30 , booked : null }
{ time : 11:45 , booked : null }
]
Note that in reality, I do not stored booked:null, I prefer to leave the field missing for space efficiency.
I know this does not answer your question, but it gives some ideas and revive your 4 days old posts.