You can install the package via composer:
composer require kenyalang/countriesTo publish the config file, you can use the following command:
php artisan vendor:publish --provider="\Kenyalang\Countries\CountriesServiceProvider" --tag=configRun the migrations to create and populate the countries and states table.
php artisan migrateBy default, the countries will be inactive. To enable them update your .env.
ENABLE_ALL_COUNTRIES=trueTo manually enable a country, you may query the desired country and use the activate function.
\Kenyalang\Countries\Models\Country::where('name', 'United States')->activate();To disable a country, you may query the desired country and use the deactivate function.
\Kenyalang\Countries\Models\Country::where('name', 'United States')->deactivate();To query only active countries, use the active scope.
\Kenyalang\Countries\Models\Country::active()->get();Add the following trait to your model to use the countries and states table:
class User extends Model
{
use \Kenyalang\Countries\Traits\HasCountry;
}To get the locale of a model use the withLocale scope:
User::withLocale()->first();composer testPlease see CHANGELOG for more information on what has changed recently.
The list of countries was taken from here. Do check it out.
The MIT License (MIT). Please see License File for more information.