This episode is for members only

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

Get started
Already a member? Sign in to continue
Playing
35. Redirecting to a confirmation page

Episodes

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

Transcript

00:00
OK, so once we've booked an appointment, we need to redirect to a confirmation page. But since we're sending this request down
00:06
with an HTTP request to a controller to make the booking, we need to return back where we want to redirect to and then do something like a window location.
00:17
So let's go ahead and get started with this. And we're going to create out the controller first of all, which will handle the confirmation page. So let's go ahead and just create out a controller here.
00:27
And let's call this confirmation controller. We'll just keep things really simple for now. And we'll go ahead and create a route out for this. So let's say confirmation.
00:38
And we'll grab the actual appointment model so we can display some details about it. But we'll do this with the UUID. So the UUID that gets generated will be generated with the URL.
00:50
OK, so we'll use that confirmation controller here. And let's go ahead and give this a name. And we'll just say confirmation. OK, so let's go ahead and open this up.
01:00
And we'll go ahead and use an invoke here. And we just won't do anything for now. We'll look at the actual redirection itself. But we should now be able to redirect.
01:08
So I've gone ahead and cleared out any appointments that are in here. Let's go over and make a booking. And then we'll manually put this.
01:15
And then we'll look at the redirect. So let's just book in for 10 o'clock. It doesn't really matter here. Let's go and book an appointment.
01:23
And of course, that should have been created in the database. So we'll grab the UUID. Let's go ahead and create out a new tab with this in here. And let's go over to that confirmation page.
01:35
And once again, just grab the UUID. And there we go. So there is our page. We know it's working.
01:40
OK, so what we're going to do is go over to our appointment controller. And when this has been created, we're going to just return a response in here, again with JSON.
01:53
But this time, we're going to use a redirect. So we did that earlier when we returned an error. There was a conflict. But now we're just returning the kind of successful response.
02:04
So the name of this is confirmation. So we can just very easily build up the route to the confirmation. And of course, the appointment gets created up here.
02:13
We can just assign that to a variable and then include it in here. And that will nicely build the URL up for us. Great.
02:20
OK, so if we come over to the checkout page where we're actually making this request, what we can now do is take that redirect back from the successful response. We already handled the error earlier.
02:31
And we can just do a really simple window location on this. It's not the ideal solution. But of course, we can't actually do a standard Laravel redirect here.
02:39
So this is the next best thing. OK, so let's go ahead and test this out and book another appointment. And we should be redirected over to that empty page.
02:49
So let's go ahead and make a booking. And there we go. Great. So we're going to build this page out in the next episode.
37 episodes4 hrs 49 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 build a simple UI with Alpine.js, with 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 Laravel!

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

Episode discussion

No comments, yet. Be the first!