
<div>
{{--Frequently used Layout--}}
{{--You can copy this when you create a new Livewire component--}}
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('Enter_Title_here') }}
</h2>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 bg-white border-b border-gray-200">
{{--Code in here --}}
</div>
</div>
</div>
</div>
</div>
Commands Used
php artisan make:model Category -m
php artisan make:model Post -m
php artisan make:model Tag -m
php artisan make:model PostTag -m
You can download and copy these model relationships
Commands Used:
npm i bootstrap-icons
npm i daisyui
Links :
Bootstrap icons
https://icons.getbootstrap.com/
Daisy ui
https://daisyui.com/docs/use/
Commands Used
php artisan make:livewire Category
Create and manage nested categories with a Livewire form, using inputs for name, can have children, and up dependency with parent IDs, plus validation and category submission.
Add a delete button and actions for categories, using Livewire to pass category IDs, handle parent and child categories, and hide deletion for app dependencies to ensure safe removal.
Learn to safely delete categories in a Laravel app by checking for posts and children, preventing deletion when present, and delivering clear session flash feedback for errors and successes.
Commands Used
php artisan make:livewire Tag
Add a delete button for tags and implement backend logic to prevent deletion when a tag is an app dependency or has related posts, with clear session feedback.
Commands Used
php artisan make:livewire Post.CreatePost
Add category selection to the post form with a daisy ui dropdown, remove delete buttons, adjust layout, and pass the selected child category ID to the backend.
Submit and save a post by selecting a category, validating inputs, and persisting the post to the database with optional tag linkage and slug generation.
Commands Used
php artisan make:livewire Home
Add a template to query posts by category and build a dynamic categories grid that filters by parent and child relationships, and prevents duplicates.
Command Used
php artisan make:livewire Search
Learn to fetch all child categories recursively in a Laravel app, gather their IDs, and retrieve posts belonging to those subcategories.
Get all posts from all categories by using child IDs, building a collection, and rendering with nested for-each loops in blade; this covers basic category management for e-commerce and blogs.
Use tags to create a recommended posts tag and attach it to posts, then query by tag on the home page for fast, eager-loaded recommendations.
Every website that uploads any sort of content dynamically will need a category management system , in this course I show you the right way to manage categories and tags for your Laravel website be it a `blog , E-commerce
I will also show you how you can query posts based on categories and tags and also how to remove and add posts from categories . All the files are available for download in the resources
Because this is an important part of every website , we are going to dive deep into managing parent categories , Sub categories including all it's children so that you can manage website queries efficiently
We are also going to create 4 separate pages in this course
# 1.Category Management Page
in this page we are going to :
To create a form where we can submit our new categories
Create a section where we ca view and see our created categories
Create a tree view for our categories
Be able to assign children to parent categories -unlimited children
Be able to delete categories and provide feedback to our user ....... etc
# 2.Tag Management Page
we are going to:
Create new tags, submit and save to database
Have a section where we can see our available tags
Choose whether a tag is an app dependency or not ?
Delete our tags, if it is deletable provide feedback to the front end
# 3.Create Post Page
In the create post page , we are going to:
Assign a new post to a category
Show all the parent of the selected category in a nice tree view : 'parent >child >child1 >selectedChild'
be able to assign a tag to our new post (optional )
add a title to our new post
add an image to our new post
submit and save out new post to our database
# 4.Home page
In the home we will:
Create a layout and show all our posts on our landing page
Create a section which list all available categories in our database , so that when we click on a category we will be able to display all posts related to that category
Have a section which show all posts related to a particular tag
# 5. Search Page
In the search page we are going to:
receive a category ID
Get all posts related to that category ID
Check if the received category has any children Category
If it has children , then get all children of the Category and also get all posts related to those child categories
Create a collection where we can combine the results of two queries
Display the results be creating a foreach function in our blade