filmov
tv
Seed Countries in Laravel App | How to Add Country List in Laravel? | Seed Countries in Databse
Показать описание
This article will give you example of how to add country list in laravel. you can understand a concept of laravel country list. i explained simply step by step laravel get country list. This tutorial will give you simple example of laravel countries list seeder.
In this example, we will create simple seeder for all country lists. so when ever you need to add country list in your laravel app then this example will help you. after run seeder we will use that country list in form.
so let's follow bellow steps. this example you can also use in laravel 6, laravel 7, laravel 8 and laravel 9 app.
Step 1: Install Laravel
first of all we need to get fresh Laravel 8 version application using bellow command, So open your terminal OR command prompt and run bellow command:
composer create-project --prefer-dist laravel/laravel blog
Step 2: Create Seeder and Country Model
here, we will create migration for countries table. so let's create migration as bellow:
php artisan make:migration create_countries_table
now let's run migration:
php artisan migrate
next, add soft delete facade in user model as like bellow:
Step 3: Create Seeder
In this step, we need to create add seeder for country lists.
Create Seeder with bellow command
php artisan make:seeder CountrySeeder
now let's run seeder:
php artisan db:seed --class=CountrySeeder
Step 4: Create Route
In this is step we need to create some routes for add to cart function.
Step 5: Create Controller
in this step, we need to create CountryController and add following code on that file:
Step 6: Create Blade Files
here, we need to create blade files for country. so let's create one by one files:
Now we are ready to run our example so run bellow command so quick run:
php artisan serve
You can get the countries List:
You can get the countries array list form by given below link
Do you want to get learn more about the laravel, let's take eye on given below series.
Stripe Integration with Laravel cashier
Laravel step by step guide
Laravel Advance series
Laravel Multi role authentication
Laravel fullCalendar js series
Laravel Solutions series
#php
#phplaravel
#laravel
#webdevelopment
#cdl
#career_development_lab
#hadayatniazi
#coding
#technology
In this example, we will create simple seeder for all country lists. so when ever you need to add country list in your laravel app then this example will help you. after run seeder we will use that country list in form.
so let's follow bellow steps. this example you can also use in laravel 6, laravel 7, laravel 8 and laravel 9 app.
Step 1: Install Laravel
first of all we need to get fresh Laravel 8 version application using bellow command, So open your terminal OR command prompt and run bellow command:
composer create-project --prefer-dist laravel/laravel blog
Step 2: Create Seeder and Country Model
here, we will create migration for countries table. so let's create migration as bellow:
php artisan make:migration create_countries_table
now let's run migration:
php artisan migrate
next, add soft delete facade in user model as like bellow:
Step 3: Create Seeder
In this step, we need to create add seeder for country lists.
Create Seeder with bellow command
php artisan make:seeder CountrySeeder
now let's run seeder:
php artisan db:seed --class=CountrySeeder
Step 4: Create Route
In this is step we need to create some routes for add to cart function.
Step 5: Create Controller
in this step, we need to create CountryController and add following code on that file:
Step 6: Create Blade Files
here, we need to create blade files for country. so let's create one by one files:
Now we are ready to run our example so run bellow command so quick run:
php artisan serve
You can get the countries List:
You can get the countries array list form by given below link
Do you want to get learn more about the laravel, let's take eye on given below series.
Stripe Integration with Laravel cashier
Laravel step by step guide
Laravel Advance series
Laravel Multi role authentication
Laravel fullCalendar js series
Laravel Solutions series
#php
#phplaravel
#laravel
#webdevelopment
#cdl
#career_development_lab
#hadayatniazi
#coding
#technology