Seed Countries in Laravel App | How to Add Country List in Laravel? | Seed Countries in Databse
HTML-код
- Опубликовано: 27 мар 2022
- 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:
app/Models/County.php
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
database/seeders/CountrySeeder.php
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.
routes/web.php
Step 5: Create Controller
in this step, we need to create CountryController and add following code on that file:
app/Http/Controllers/CountryController.php
Step 6: Create Blade Files
here, we need to create blade files for country. so let's create one by one files:
resources/views/country.blade.php
Now we are ready to run our example so run bellow command so quick run:
php artisan serve
You can get the countries List:
github.com/umpirsky/country-list
You can get the countries array list form by given below link
bit.ly/37NH0Sg
Do you want to get learn more about the laravel, let's take eye on given below series.
Stripe Integration with Laravel cashier
• Laravel Tips
Laravel step by step guide
• Laravel step by step g...
Laravel Advance series
• Laravel Advance Features
Laravel Multi role authentication
• Laravel Multi Role Aut...
Laravel fullCalendar js series
• FullCalendar js in Lar...
Laravel Solutions series
• Laravel Solutions
If you are facing any problem during development, you can post your queries free of cost at solutions.cdlcell.com so our team will respond to you within 24 hours.
If you need paid help from us, please visit solutions.cdlcell.com/user/in... to process a contract with us.
* Contact us: contact@cdlcell.com
* Our website: cdlcell.com
* My Twitter: / hadayatniazi3
* My FB: / hadayatniaziofficial
Follow us on LinkedIn: / cdlcell
Follow us on Tiktok: / cdlcell
Join us on Instagram: / cdlcell
Follow us on Facebook: / cdlcellpk
Join our Laravel Developers whatsapp group: chat.whatsapp.com/JSA8qZZGVbP...
#php
#phplaravel
#laravel
#webdevelopment
#cdl
#career_development_lab
#hadayatniazi
#coding
#technology Наука
Thanks