agoalofalife / geography
Requires
- php: >=7.2
- illuminate/config: ^8.0
- illuminate/database: ^8.0
- illuminate/support: ^8.0
- symfony/console: ^5.0
Requires (Dev)
- mockery/mockery: ^0.9.9
- phpunit/phpunit: ^6.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
The geography of the regions
What is it?
This package solves the problem with the hierarchy of countries, regions, settlements in your database. A few commands in the console, you deploy all the necessary the country , regardless of country and language.
The installation of the package
For installation, you must run the command from composer
composer require agoalofalife/geography
Data migration
Run the command :
vendor/bin/geography install
Following the instructions step by step, continue to enter information.
- Database selection
======================================
Please choose your database type :
[ 0 ] mysql
[ 1 ] postgres
- Choice your host
Enter host for database , please : localhost
- The name of the database:
Enter database name, please : test
- The user in the database:
Enter database username, please : root
- The password in the database (not shown):
Enter database password, please :
- To select the language:
Please select your native language :
[0] ru
[1] en
[2] ua
[3] be
[4] es
[5] fi
[6] de
[7] it
>
- Choose the country you want to migrate, for example I need a few countries (Australia and Brazil), respectively, I would need to enter : AU,BR
the list of countries you can see here 3166-1 alpha-2
you can specify multiple countries separated by commas
example EN, RU
Enter the country you wish to migrate, please :
After some time, depending on the volume of information you will see in my database three tables :
- Country
- Regions
- Сities
You have just selected: AU,BR
3/3 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Congratulations to all successful!
Integration with Laravel
Since the environment Laravel uses for its tables Seeder and Migration, we can freely copy it to your project Laravel!
vendor/bin/geography migrate:laravel
After you get your files in a folder database and config.
To configure your language and countries you want to migrate, you must change the configuration file in config/geography.php :
return [
// Your native language
// 0 — Russian,
// 1 — Ukrainian,
// 2 — Belarusian,
// 3 — English,
// 4 — Spanish,
// 5 — Finnish,
// 6 — German,
// 7 — Italian.
'locale' => 0,
// Country you wish to migrate
// standard 3166-1 alpha-2
// example RU,AU
'country' => 'RU',
'nameTable' => [
'country' => 'country',
'regions' => 'regions',
'cities' => 'cities'
],
'access_token' => ''
];
Next, you need to perform :
composer dump
php artisan migrate
php artisan db:seed
или для seeder :
php artisan db:seed --class=CountryTableSeeder
php artisan db:seed --class=RegionsTableSeeder
php artisan db:seed --class=CitiesTableSeeder
After you can easily remove the package and what not to worry!