The Laravel-World is a Laravel package which provides a list of the countries, states, cities, timezones, currencies and languages.
It can be consumed with the World Facade
Via Composer
composer require bkfdev/laravel-world
php artisan vendor:publish --force --provider="Bkfdev\World\LaravelWorldServiceProvider"
<?php
return [
/*
|--------------------------------------------------------------------------
| Allowed countries to be loaded
| Leave it empty to load all countries
|--------------------------------------------------------------------------
*/
'allowed_countries' => [],
/*
|--------------------------------------------------------------------------
| Disallowed countries to not be loaded
| Leave it empty to allow all countries to be loaded
|--------------------------------------------------------------------------
*/
'disallowed_countries' => [],
/*
|--------------------------------------------------------------------------
| Supported locales.
|--------------------------------------------------------------------------
*/
'accepted_locales' => [
'ar',
'en',
/* 'bn',
'br',
'de',
'es',
'fr',
'ja',
'kr',
'nl',
'pl',
'pt',
'ro',
'ru',
'zh', */
],
/*
|--------------------------------------------------------------------------
| Enabled modules.
| The cities module depends on the states module.
|--------------------------------------------------------------------------
*/
'modules' => [
'states' => true,
'cities' => true,
'timezones' => true,
'currencies' => true,
'languages' => true,
],
/*
|--------------------------------------------------------------------------
| Migrations.
|--------------------------------------------------------------------------
*/
'migrations' => [
'countries' => [
'table_name' => 'world_countries',
'optional_fields' => [
...
php artisan migrate
php artisan world:init
Or you may add some countries by running this command :
php artisan world:add us sa dz
It's just an eloquent so you may run whetever your want
use Bkfdev\World\World;
$countries = World::Countries();
$country = World::getCountryByCode($code);
return :
[
"id" => 1
"iso2" => "DZ"
"name" => "Algeria"
"status" => 1
"phone_code" => "213"
"iso3" => "DZA"
"native" => "الجزائر"
"region" => "Africa"
"subregion" => "Northern Africa"
"latitude" => "28.00000000"
"longitude" => "3.00000000"
"emoji" => "🇩🇿"
"emojiU" => "U+1F1E9 U+1F1FF"
]
$country = World::getCountryByName($name);
$states = World::getStatesOfCountry($code);
Please see the changelog for more information on what has changed recently.
composer test
Please see contributing.md for details and a todolist.
If you discover any security related issues, please email bkfdev@gmail.com instead of using the issue tracker.
MIT. Please see the license file for more information.