All Projects → khsing → Laravel World

khsing / Laravel World

Licence: mit
provide countries, states, and cities relations and database.

Projects that are alternatives of or similar to Laravel World

Countries States Cities Database
🌍 World countries, states, regions, provinces, cities, towns in JSON, SQL, XML, PLIST, YAML, and CSV. All Countries, States, Cities with ISO2, ISO3, Country Code, Phone Code, Capital, Native Language, Timezones, Latitude, Longitude, Region, Subregion, Flag Emoji, and Currency. #countries #states #cities
Stars: ✭ 1,130 (+409.01%)
Mutual labels:  city, country, state, region
csc picker
A flutter package to display a country, states, and cities. In addition it gives the possibility to select a list of countries, States and Cities depends on Selected, also you can search country, state, and city all around the world.
Stars: ✭ 25 (-88.74%)
Mutual labels:  country, state, city
IP2Location-PHP-Module
This module is a PHP module that enables the user to find the country, region, city, coordinates, zip code, ISP, domain name, timezone, connection speed, IDD code, area code, weather station code, weather station name, mobile, usage types, address type, IAB category, etc that any IP address or host name originates from.
Stars: ✭ 154 (-30.63%)
Mutual labels:  country, city, region
ip2location-nginx
Nginx module that allows user to lookup for geolocation information using IP2Location database.
Stars: ✭ 33 (-85.14%)
Mutual labels:  country, city, region
Laravel Translatable
A Laravel package for multilingual models
Stars: ✭ 624 (+181.08%)
Mutual labels:  translation, database, laravel
Tr Geozones
Ülkeler ve Türkiye İl İlçe Semt Mahalle ve Posta Kodu Veritabanı (Laravel)
Stars: ✭ 46 (-79.28%)
Mutual labels:  laravel, city, state
IP2Location-C-Library
IP2Location C library enables the user to find the country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather station code, weather station name, mobile, usage types, etc that any IP address or hostname originates from.
Stars: ✭ 37 (-83.33%)
Mutual labels:  country, city, region
Laravel Translatable
It's a Laravel database translations manager
Stars: ✭ 47 (-78.83%)
Mutual labels:  translation, database, laravel
Laravel Country State
A helper to list countries & states in English in Laravel 5.1+
Stars: ✭ 77 (-65.32%)
Mutual labels:  laravel, country, state
State
Finite state machine for TypeScript and JavaScript
Stars: ✭ 118 (-46.85%)
Mutual labels:  state, region
Backup Manager
Database backup manager for dumping to and restoring databases from S3, Dropbox, FTP, SFTP, and Rackspace Cloud
Stars: ✭ 1,589 (+615.77%)
Mutual labels:  database, laravel
Config
Manage Laravel configuration by persistent storage
Stars: ✭ 139 (-37.39%)
Mutual labels:  database, laravel
Laravel Settings
Store key value pair in database as settings
Stars: ✭ 107 (-51.8%)
Mutual labels:  database, laravel
Ardent
Self-validating, secure and smart models for Laravel's Eloquent ORM
Stars: ✭ 1,412 (+536.04%)
Mutual labels:  database, laravel
Laravel Database Schedule
Manage your Laravel Task Scheduling in a friendly interface and save schedules to the database.
Stars: ✭ 94 (-57.66%)
Mutual labels:  database, laravel
Lara Lens
Laravel package for display diagnostic (config, database, http connections...)
Stars: ✭ 96 (-56.76%)
Mutual labels:  database, laravel
Laravel Db Profiler
Database Profiler for Laravel Web and Console Applications.
Stars: ✭ 141 (-36.49%)
Mutual labels:  database, laravel
Deeply
PHP client for the DeepL.com translation API (unofficial)
Stars: ✭ 152 (-31.53%)
Mutual labels:  translation, laravel
Laravel Sync Migration
Developer tool helps to sync migrations without refreshing the database
Stars: ✭ 89 (-59.91%)
Mutual labels:  database, laravel
Laravel Scout Postgres
PostgreSQL Full Text Search Engine for Laravel Scout
Stars: ✭ 140 (-36.94%)
Mutual labels:  database, laravel

Laravel World Database

This package focused on World Countries, Regions, and Cities database with locale support for Laravel.

Conceptions

There are 5 main objects in this package.

  • World: the earth world.
  • Continent: 7 continent
  • Country: 248 countries
  • Division: Divisions such as state/province.
  • City: the last level of region, some cities up to Country, some up to Division.

Attributes

Common attributes:

  • name: Common name of region(english).
  • full_name: Full name or official name(english).
  • code: ISO-3166-1-alpha2/ISO-3166-2 code
  • local_name: translation of Common name
  • local_full_name: translation of full name
  • local_alias: alias in different language
  • local_abbr: Abbreviation

Country spec attributes:

  • emoji: Emoji flag of country
  • capital: Captial of this country
  • code_alpha3: Code of ISO-3166-1-alpha3
  • currency_code: ISO-4177 Currency Code, e.g. USD, CNY
  • currency_name: ISO-4177 Currency Name,
  • local_currency_name: ISO-4177 Currency name in locale

Example:

use Khsing\World\World;
$china = World::getByCode('cn');
$china->setLocale('zh-cn');
$china->name; // China
$china->local_name; // 中国
$china->full_name; // People's Republic of China
$china->local_full_name; // 中华人民共和国
$china->emoji; // 🇨🇳
$china->callingcode; // 86
$china->code; // CN
$china->code_alpha3; // CHN
$china->has_division; // true
$china->currency_code; // CNY
$china->currency_name; // Yuan Renminbi
$china->local_currency_name; // 人民币

Localization

Right now, only English(default and fallback) and Chinese-Simp zh-cn are supported. Locale settings is following Laravel project settings in config/app.php.

Setup

  • composer require
composer require khsing/world
  • Add Service Provider into config/app.php, (Only required before Laravel 5.5)
'providers' => [
    // ...
    Khsing\World\WorldServiceProvider::class,
]
  • Publish and init
php artisan vendor:publish --force --provider="Khsing\World\WorldServiceProvider"
composer dump-autoload
php artisan world:init

Usage

  • get all Continent
use Khsing\World\World;

World::Continents()

  • get all Countries
use Khsing\World\World;

World::Countries()
  • get country/city/division by code
use Khsing\World\World;

World::getByCode('cn'); // iso-3166 alpha 2 code
World::getByCode('chn'); // iso-3166 alpha 3 code
World::getByCode('cn-11'); // Beijing
  • get countries belong to a continent
use Khsing\World\Models\Continent;

$asia = Continent::getByCode('AS');
$countries = $asia->countries()->get();
// or use children method
$countries = $asia->children();
  • get continent or parent
$china = Country::getByCode('cn');
$asia = $china->parent();
  • get division/state/province via Conutry
$china = Country::getByCode('cn');
$provinces = $china->divisions()->get()
// or use children method
$provinces = $china->children();
  • get cities via Country or Division.
$china = Country::getByCode('cn');
// check has_division to determine next level is division or city.
$china->has_division; // true, otherwise is false
$regsions = $china->children();

Contributions

If you want contribute to this library, issue and pr are welcome. please following those steps.

  1. start a new laravel project and install this library.
  2. install orangehill/iseed.
  3. modify datas via sql.
  4. generate seeds via artisan iseed world_cities,world_cities_locale,world_continents,world_continents_locale,world_countries,world_countries_locale,world_divisions,world_divisions_locale
  5. replace delete() with truncate(), cd database/seeders/ && sed -i 's/->delete()/->truncate()/g' World*.php
  6. copy seeds files into library.
  7. commit your work. ;)

TODO

  • change the way to seed data, eg. loading data from json?
  • add front-end support
  • find a way to update dataset

Data Sources

Thanks

About

This package published under MIT license. If you have any question or suggestion, please feel free to submit a issue, or email me Guixing<khsing.cn(AT)gmail.com>.

Have a nice day.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].