This episode is for members only

Sign up to access "Build an Appointment Booking System With Livewire" right now.

Get started
Already a member? Sign in to continue
Playing
14. Excluding time already passed today

Episodes

0%
Your progress
  • Total: 3h 4m
  • Played: 0m
  • Remaining: 3h 4m
Join or sign in to track your progress

Transcript

00:00
If we look at the starting period for the period collection we've got, you'll notice something strange. This starts at 9 o'clock.
00:06
Now, at the moment, it is not 9 o'clock in the morning. So really what we want to do is exclude the period at the start of the day that has already passed. So we're going to go ahead and do that now.
00:18
Now, before we do that, let's go over to our web routes. And we're going to go and bring back our set test now. We're going to set this to today. But we're going to set the time from a time string.
00:29
I'm going to set this to 10 o'clock. So we really should only have availability after 10 o'clock. That's not going to be the case because we haven't set this up yet.
00:40
Okay, so we're going to go over to our schedule availability. And just after we have added our schedule exclusions, we're going to go ahead and call another method to exclude the time passed today.
00:50
So let's call this exclude time passed today. That kind of makes sense. And we don't necessarily need to pass anything through to this because we just want to take out a period
01:01
that has been from the start of the day up until now. Okay, let's go ahead and build in this method. So exclude time passed today. And let's see what we need to do here.
01:11
So again, we need to subtract a period. So let's go and take the periods and say this periods subtract. Into here, we'll go ahead and make out a period.
01:22
This needs to be now start of day. So the very start of the day. And then we just need to figure out what we want to subtract from this.
01:31
So what I typically do is say end of hour. So the end of the current hour is when our availability starts. So let's go and say precision
01:41
and we'll set this to minute of course. And let's take a look at the result and see if it's what we expected. Okay, so let's go into our periods here,
01:50
look at the start date and yeah, we are starting now at 11 o'clock. So if it's 10 o'clock, we go to the end of the hour and we can only book from 11.
01:59
Now you can adjust this and change this around if you want to. So for example, you could say add a half an hour and only allow appointments to be booked
02:08
after half an hour. But really within booking systems, you're not gonna find someone booking an appointment within the actual hour that they're booking.

Episode summary

In this episode, we tackle a little issue with how our availability schedule works. By default, our system was showing availability starting at the very beginning of the work day (like 9:00 AM), even if that time had already passed. Obviously, we don't want users booking appointments in the past!

So, we walk through how to automatically exclude time that has already elapsed today. We start by showing what the problem looks like, then jump into our routes to set up a scenario where the booking window should start later – for instance, if it's currently 10:00 AM, bookings should only show up from 11:00 AM onwards.

To do this, we add a new method called excludeTimePassedToday. This method chops off the part of the day that's already gone and only leaves times in the future for people to book. We use the start of the current day up to the end of the current hour as the period to subtract.

By the end, we've fine-tuned our booking system so users can only make appointments for future times, and we chat a bit about how you might customize this to, say, add a buffer before new appointments can be made. Super handy if you want your booking system to feel a bit smarter and avoid those awkward “booking in the past” moments!

Episode discussion

No comments, yet. Be the first!