Playing
01. Introduction and setup

Transcript

00:00
So how do we create nested categories in Laravel and also show breadcrumbs along with them categories, the deeper we get?
00:08
Well, that's exactly what we're going to look at in this course. Let's go ahead and look at a demo of this. We'll get a really quick project set up. And then for the rest of the course, we'll look at creating out these
00:18
nested categories in the database, going ahead and bringing in breadcrumb functionality and also doing some customizations and look at some other tips as well. Okay.
00:28
So I'm going to go ahead and click on shoes here. And as you can see immediately, we're put into the shoes category and this shows the two subcategories underneath this course, we can go back to the categories page that we were just on.
00:39
And we can go back to the dashboard as well. I'm using the dashboard as an example, but this would likely be your homepage. Okay. Let's go into shoes then into boots.
00:48
And then we've got even more subcategories in here, which we would potentially list out products in. And we're all the way into the last in the list. And of course we can just go back to any of these categories to continue
00:59
browsing, and this really helps usability of when you have very nested deep categories in any of the sites that you're building. Okay. So that's pretty much what we're looking at.
01:09
Let's go ahead and set up a fresh project here so we can get started. And I'm going to show you how to achieve everything we've just looked at. So if you already have an existing project, of course, feel free to skip on to the next episode, but let's get a quick project
01:21
set up so we can get this working. Okay. Let's use Laravel's installer to create our new projects. And I'm just going to call this breadcrumbs.
01:29
We're going to choose the Laravel breeze starter kit just because it gives us some templating and also includes tailwind as well, which we're going to be using to start this up. You can customize the styling of whatever you're building with the breadcrumbs,
01:40
but we'll go ahead and use tailwind for now. Okay. So we're just going to choose the blade with Alpine option here, but of course this is going to work if you're using live wire as well, and let's go ahead
01:51
and say that we don't want to use dark mode and go through the rest of these options. Okay. We'll go ahead and choose MySQL as our database driver, and let's go
01:58
ahead and run the default migrations with this. And once this finishes, we should be good to go. Let's just have a look at our database really quickly. And yeah, that looks like it's worked.
02:06
Let's head back over and just wait for this to finish and get this open in our editor. Okay. So once that's done, let's open this up in our editor and we should be good to go.
02:15
Let's go over to the browser and open this up and we'll go ahead and register an account and get into the dashboard. Of course, if you are doing this in an existing application, you might not want functionality to be only available when you're signed in, but we'll use this as
02:30
an example. Okay. So we're into our application. Let's go over and look at using nested sets for our categories.

Episode summary

Welcome to the course! In this opening episode, we kick things off by explaining what you'll be learning: how to build nested categories in Laravel and display breadcrumbs as users navigate deeper into those categories. We check out a demo where clicking into categories like "shoes" reveals subcategories, with breadcrumbs showing the full path, helping users keep track of where they are. It's a handy feature for any site with a lot of nested navigation!

Next, we walk through setting up a fresh Laravel project so you can follow along from scratch. We use the Laravel Breeze starter kit because it comes with some helpful templating and Tailwind CSS out of the box, making things look decent right away. We opt for Blade with Alpine, but you can use Livewire if that's your thing. We also decide on MySQL for our database and get the initial migrations run.

Finally, we take a quick look around our new app, register an account, and get ready to start implementing nested sets for our categories. If you've already got a project up and running, feel free to skip ahead—but if not, stick with us as we get everything set up and ready to go!

Episode discussion

No comments, yet. Be the first!