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
19. Removing empty slots

Episodes

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

Transcript

00:00
So let's tidy up our list of slots and get rid of any of the slots that we've got in here where there are just no employees. There's no point including these slots like at midnight when none of our employees can do this. So aside from returning the range down here which we're eventually going to need to do, after we've done everything let's go ahead and remove empty
00:19
slots. So I'm going to go ahead and call a remove empty slots method in here and let's pass our range into here so we can modify it. Okay so let's create out that method, remove empty slots and of course into here we are going to take in a date collection of our slots. We'll just call that range and then in here we want to iterate over them. We want to filter it basically because
00:42
we're working with a lot of our collection this is going to be very easy to filter. So we're going to return the filtered range and actually just up here we'll need to assign this because we're going to return the filtered value. So let's return range filter and the way this works is if you've never worked with a collection filter before we could just return false in here
01:03
like so and let's take a look at what we get. So yeah we just end up with nothing if we make sure we dump this out. So let's die dump on our availability give that a refresh and yeah we just end up with an empty collection. So not only do we want to filter out the slots we also want to filter out the days as well that's really important. So for each of these we get a date
01:25
our custom date class and what's the condition around this? Well the first thing that I'm going to do is go down here and return true just because we are going to filter out and return false for each of the slots that don't have anything and then we're just going to go and reassign the slots but filter them at the same time. So we're kind of filtering the dates but we're also filtering the
01:44
slots within them dates at the same time. So let's go ahead and say on the date that we've got let's go through the slots and filter them. So we'll end up with all of our filtered slots once we're done with this. So let's pull in our closure here pull in our slot for each of these and then what's the condition? So let's just return false for now go over we have two of our dates here but we have
02:08
no slot so we're getting there we just need this condition. So the condition of this is that the slot actually has employees so we could either do this directly using employees and empty for example or is not empty or we could say has employees and create a little helper over on our slot. So let's create that now so let's say has employees and we can very easily here return
02:34
the employees and is not empty there we go so as long as this is not empty then that's going to return. Okay let's try this out give it a refresh let's check today's date and yeah so we only have three slots of five slots available now so we have got 12 o'clock everything that we would normally expect and obviously these have employees within them that can fulfill that slot.
36 episodes3 hrs 4 mins

Overview

Building an availability calendar and booking system is a notoriously difficult problem to solve. That’s exactly what we’re going to cover in this course.

Step by step, we’ll build an appointment slot generator that calculates availability based on employee schedules, employee’s booked time off, the length of service chosen, existing appointments, and cancelled appointments.

For maximum flexibility, we’ll also allow multi-employee availability checks, so we’ll be able to see every employee who can perform a service (and their available slots).

To finish up, we’ll create an entire booking flow with Livewire, including a beautiful booking calendar that shows detailed availability across multiple dates, the ability to choose a time slot — and finally the ability to book an appointment.

Phew. We’ve got a lot to learn — let’s build a booking system with Livewire!

Alex Garrett-Smith
Alex Garrett-Smith
Hey, I'm the founder of Codecourse!

Episode discussion

No comments, yet. Be the first!