nathandunn/laravel-countries

v3.0.0 2023-02-18 22:27 UTC

This package is auto-updated.

Last update: 2024-11-19 02:10:42 UTC


README

Packagist GitHub Workflow Status (master branch) Code Climate Codecov StyleCI

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.

Installation

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

Syncing countries

Console command

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.

Seeder

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);
    }
}