►Laravel 10 Tutorial Playlist: • Laravel 10 Tutorial: Make Admin Panel...
In Part-34, we will start working on eshop-related modules like Categories, Products, Attributes and so on.
We will first start working on the categories module in which we will add the below categories.
Clothing
Electronics
Appliances
Categories may have Sub Categories like below:-
Clothing - Men, Women, Kids
Electronics - Mobiles, Computers, Televisions, Cameras, Headphones
Appliances - Air Conditioners, Refrigerators, Washing Machines
Sub Categories may also have Sub Sub Categories like below:-
Men - Shirts, T-Shirts
Women - Tops, Dresses
Kids - T-shirts, Shorts
In this video, we will create a categories table with migration and will also add one category in it with Seeding though later on we will add category from admin panel.
We will also create a controller and model for categories.
1) Create categories table :-
First of all, we will create categories table with migration. Create migration file with name create_categories_table for creating categories table with below columns:-
id, parent_id, category_name, category_image, category_discount, description, url, meta_title, meta_description, meta_keywords and status
So, we will run below artisan command to create a migration file for categories:-
php artisan make:migration create_categories_table
Open the create_categories_table migration file and add all required columns mentioned earlier.
Now, we will run below artisan command to create a categories table with required columns:-
php artisan migrate
Now categories table has been created with all the required columns.
2) Create Category model :-
Create Category model by running below command :-
php artisan make:model Category
3) Create CategoryController :-
Create CategoryController in Admin folder at /app/Http/Controllers/Admin/ by running below command :-
php artisan make:controller Admin/CategoryController
Now, We will create a Seeding for categories table to insert a few categories like Clothing, Electronics and Appliances and we will also create few sub categories under Clothing category like Men, Women and Kids.
4) Writing Seeder / Create CategoryTableSeeder file :-
First of all, we will generate a seeder and create a CategoryTableSeeder file from which we will add few categories and sub-categories for the categories table.
Run below artisan command to generate Seeder and create CategoryTableSeeder file:-
php artisan make:seeder CategoryTableSeeder
Above command will create the CategoryTableSeeder.php file at \database\seeds\
Now open the CategoryTableSeeder file and add records for the categories.
5) Update DatabaseSeeder.php file:-
Now update DatabaseSeeder.php file located at database/seeds/ to add CategoryTableSeeder class as shown in video.
6) Run below command :-
Now run below command that will finally insert category into categories table.
php artisan db:seed
In next video, we are going to display Categories & Sub Categories in the admin panel.
►Click here to subscribe for Laravel & other updates - / stackdevelopers
Popular Stack Developers Series that can help you:-
►Laravel Multi-Vendor E-commerce Website - • Laravel Multi Vendor Tutorial
►React JS Tutorial for Beginners with Laravel - • React JS Tutorial with Laravel for Be...
►Laravel Tutorial for Beginners - • Laravel Tutorial for Beginners | Adva...
►GIT Tutorial for Beginners - • Git Tutorial for Beginners | Create y...
►Laravel API Tutorial - • Laravel API Tutorial | Create API fro...
►Laravel Interview Questions - • Laravel Interview Questions & Answers...
►jQuery Tutorial - • jQuery Tutorial
►Laravel Basic E-commerce Series - • Make Admin Panel / E-commerce Website...
►Laravel Dating Series - • Make Dating / Social Networking Websi...
►Join this channel to get the complete source code of all series:
/ @stackdevelopers
Follow Stack Developers on Social Media to get updates and resolve your queries
►Like Facebook Page to get updates - / stackdevelopers2
►Join Facebook Group to resolve your queries - / stackdevelopers
►Follow on Instagram - / stackdevelopers2
►Follow on GitHub - https://github.com/stackdevelopers
#laravel10 #laravel10tutorial #laravel