Laravel Countries provides database migrations and syncing capabilities in order to sync continents, currencies and currencies. The package uses the REST Countries API to maintain an up-to-date list of countries. This is in contrast to a lot of existing libraries, which rely on data stored in the repository and often becomes out-of-date.
You can install the package via Composer:
composer require nathandunn/laravel-countries
Once the package has been installed, run Laravel's migration command to create the base tables.
php artisan migrate
The primary method of syncing companies is by running the following command:
php artisan countries:sync
This will fetch and sync data from the API.
You may find you'd like to add syncing countries as part of your development/staging environment. You may add NathanDunn\Countries\Database\Seeders\CountrySeeder
to your DatabaseSeeder
.
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use NathanDunn\Countries\Database\Seeders\CountrySeeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeders.
*
* @return void
*/
public function run()
{
$this->call(CountrySeeder::class);
}
}