phillipvarsted's avatar

Booking/Appointment reservation with time slots

Hello, this is my first time creating a discussion here on Laracasts :)

What am I using?

I'm using Laravel 8 with Inertia JS and Vue 3.

I am currently developing a booking system for a client. At first the idea the client brought up, was that the employees needed the functionality to book customers appointments in the shop. The shop is a fitness/instructor business, where customers can be booked for a session for 30 minutes.

Recently the customer asked, if the possibility of creating an online booking functionality would be possible, and I immediately began designing, structuring and implement the features for this. After weeks of trying I ran into some issues.

Before really digging into the question, then let me describe whats needed for the booking system.

Let's say the store has different working hours throughout the week.

Example:

Monday: 9.00 AM - 5.00 PM
Tuseday: 9.00 AM - 5.00 PM
Wedensday: 9.00 AM - 5.00 PM
Thursday: 9.00 AM - 4.00 PM
Friday: 10.00 AM - 2.00 PM
Weekend: Closed

The user can then choose a date from a datepicker and should be presented with available time slots for that day.

The length of the session is 30 minutes, so a time slot should be with an interval of 30 minutes.

Example:

Monday is open from 9.00 AM to 5.00 PM. It needs a total of 21 available slots. When a slot is booked by a customer, then the time slot should not be visible for that exact date anymore.

I've tried the following already, which works, but seems to be a bit of work by the customer, and I wanted to make it as simple as possible, so the customer doesn't have to struggle when using the application.

I have the following database tables:

  • Users
  • Availabilities

As of now I am storing all possible time slots manually, and when a user books the time slot I simply just update the table row with a boolean field checking is the slot is available or not.

Is there a better way of doing this instead of storing every single time slot in the database? I've tried playing around with generating time slots for a single day without the database (which works for a single day), but I feel like I'm stuck at this point. It feels like I am filling the database with unnecessary data - for instance, if the time slot isn't being booked, then it's just sitting there.

Just the time slots alone will be 7,665 records created manually or with some help of a database seeder. But what if the customer wants to change there opening hours, does it need to seed every single records from scratch again?

If something is not clear, I'll be happy to explain further :)

Thanks in advance!

0 likes
8 replies
jlrdw's avatar

You could use

  • laravel calendar
  • look at github booking packages get ideas from code how they did it

And look for past laracast postings on booking systems, there have been a few.

In one I did I just had available slots.

chaima67's avatar

Can you please tell me how you solved this problem im on my last year of graduation and i'm stuck with this problem PLEASE HELP

chaima67's avatar

@jlrdw thank you but in my case i dont want to add events on calendar i want to calendar to contain timeslots of availble bookings for the patients to book an appointment

Snapey's avatar

@Harshita13

  • learn how to use carbon period
  • dont put available sessions in database, only put bookings
  • when showing available sessions to client, block out any sessions for which there is a booking
  • design a single view to show all available sessions AND booked sessions with client details. Staff need to see the details, but if they are a guest then hide the details
  • make sure you cater in the code for multiple sessions at the same time, eg could be treatment rooms, initially they only have one treatment room, how easily can your code adapt if they open a second?
  • handle two customers trying to book the same session at the same time
1 like

Please or to participate in this conversation.