In Part-59 of Advance E-com Series in Laravel 7, we will start working on making home page banners dynamic for our e-commerce website. We will create banners table with migration and will also add dummy banners in it with Seeding though later on we can add/update banners from admin panel. We will also create model for banners.
1) Create banners table :-
First of all, we will create banners table with migration. Create migration file with name create_banners_table for creating banners table with below columns :-
id, image, link, title, alt and status
So, we will run below artisan command to create migration file for banners :-
php artisan make:migration create_banners_table
Open create_banners_table migration file and add all required columns mentioned earlier.
Now, we will run below artisan command to create banners table with required columns :-
php artisan migrate
Now banners table has been created with all the required columns.
2) Create Banner model :-
Create Banner model by running below command :-
php artisan make:model Banner
Now, We will create Seeding for banners table to insert few test banners from seeder command.
4) Writing Seeder / Create BannersTableSeeder file :-
First of all, we will generate seeder and create BannersTableSeeder file from where we will add banner images for banners table.
Run below artisan command to generate Seeder and create BannersTableSeeder file :-
php artisan make:seeder BannersTableSeeder
Above command will create BannersTableSeeder.php file at \database\seeds\
Now open BannersTableSeeder file and add record for product image.
5) Update DatabaseSeeder.php file :-
Now update DatabaseSeeder.php file located at database/seeds/ to add BannersTableSeeder class as shown in video.
6) Run below command :-
Now run below command that will finally insert banners into banners table.
php artisan db:seed
In next video, we will display banners in admin panel with active/inactive and delete options.
Смотрите видео #59 Make E-com in Laravel 7 | Make Home Page Banners Dynamic(I) | Create Table | Migration | Seeding онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Stack Developers 01 Январь 1970, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 1,292 раз и оно понравилось 32 людям.