├── .github
└── FUNDING.yml
├── .gitignore
├── LICENSE
├── README.md
├── _config.yml
├── composer.json
├── phpunit.xml.dist
├── publishable
└── config
│ └── location.php
├── src
├── Http
│ └── Controllers
│ │ ├── Controller.php
│ │ └── LocationController.php
├── LocationServiceProvider.php
├── Models
│ ├── City.php
│ ├── Country.php
│ └── State.php
├── database
│ ├── migrations
│ │ ├── 2019_05_11_000000_create_cities_table.php
│ │ ├── 2019_05_11_000000_create_countries_table.php
│ │ ├── 2019_05_11_000000_create_states_table.php
│ │ └── 2019_12_01_000000_add_country_id_column_to_cities_table.php
│ └── seeds
│ │ ├── CitiesTableSeeder.php
│ │ ├── CountriesTableSeeder.php
│ │ ├── LocationDatabaseSeeder.php
│ │ ├── StateCityCountrySeeder.php
│ │ └── StatesTableSeeder.php
└── routes
│ └── web.php
└── tests
├── LocationRouteTest.php
└── TestCase.php
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | custom: ["https://rave.flutterwave.com/pay/trojantjkf"]
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | vendor/
2 | node_modules/
3 | npm-debug.log
4 |
5 | # Laravel 4 specific
6 | bootstrap/compiled.php
7 | app/storage/
8 |
9 | # Laravel 5 & Lumen specific
10 | public/storage
11 | public/hot
12 | storage/*.key
13 | .env.*.php
14 | .env.php
15 | .env
16 | Homestead.yaml
17 | Homestead.json
18 |
19 | # Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer
20 | .rocketeer/
21 |
22 | # PHPStorm
23 | .idea/
24 | composer.lock
25 |
26 | #PHPUnit
27 | .phpunit.result.cache
28 | build
29 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Michael Okoh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Laravel Location ▲
2 |
3 | 
4 |
5 | ## Introduction 🖖
6 | This Package offers a simple way to get Countries, Cities and States that you may need for your Application, most especially for dropdown menus.
7 |
8 | ### Step One - Install via Composer 🎼
9 |
10 | Require the package via composer into your project
11 |
12 | ```shell
13 | composer require ichtrojan/laravel-location
14 | ```
15 |
16 | 
17 |
18 | ### Step Two - Publish Configurations ⚙️
19 | Laravel location provides you with an easy way of customizing the tables used for storing Countries, States and Cities. Also, you can customisethe route prefix and middleware. To customize these you need to publish the
20 | configuration file. To publish the configuration file, run:
21 |
22 | `php artisan vendor:publish --tag=laravel-location`
23 |
24 | You will have `config/location.php` available for you to edit. The default configurations are:
25 |
26 | ```php
27 | 'countries',
31 | 'cities_table' => 'cities',
32 | 'states_table' => 'states',
33 | 'routes' => [
34 | 'prefix' => 'location',
35 | 'middleware' => 'web'
36 | ]
37 | ];
38 | ```
39 |
40 | You can go ahead and customize the `table names`, `route prefix` and `middleware` as you need before running the Migration.
41 |
42 | ### Step Three - Running Migrations
43 |
44 | > before you do this make sure your correct Database credentials are set in the `.env` file
45 |
46 | ```shell
47 | php artisan migrate
48 | ```
49 |
50 | 
51 |
52 | Finally, run the Package seeders
53 |
54 | ```shell
55 | php artisan db:seed --class=Ichtrojan\\Location\\Seeds\\LocationDatabaseSeeder
56 | ```
57 |
58 | ## Usage 🧨
59 |
60 | >**NOTE**
61 | >The routes below are prefixed with `location` which is the default configuration set in the `config/location.php`
62 | >file. If mofified, replace the prefixin your route with the correct prefix.
63 |
64 | |Route|Description|
65 | |:------------- | :----------: |
66 | |`/location/countries`|return all countries|
67 | |`/location/country/{id}`|return a single country by its ID|
68 | |`/location/states`|return all states|
69 | |`/location/state/{id}`|return a single state by its ID|
70 | |`/location/states/{countryID}`|return all states in a country using the country ID|
71 | |`/location/cities`|return all cities|
72 | |`/location/city/{id}`|return a single city by its ID|
73 | |`/location/cities/{stateID}`|return all cities in a state using the state ID|
74 |
75 | ## Test
76 | `composer test`
77 |
78 | ## Contribution
79 |
80 | Free for all, if you find an issue with the package or if a group of people somehow created a new country please send in a PR.
81 |
82 | Danke Schön
83 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ichtrojan/laravel-location",
3 | "type": "library",
4 | "license": "MIT",
5 | "authors": [
6 | {
7 | "name": "Michael Okoh",
8 | "email": "michael@okoh.co.uk"
9 | }
10 | ],
11 | "minimum-stability": "dev",
12 | "autoload": {
13 | "psr-4": {
14 | "Ichtrojan\\Location\\": "src/"
15 | }
16 | },
17 |
18 | "autoload-dev": {
19 | "psr-4": {
20 | "Ichtrojan\\Location\\Test\\": "tests"
21 | }
22 | },
23 | "scripts": {
24 | "test": "vendor/bin/phpunit tests"
25 | },
26 | "extra": {
27 | "laravel": {
28 | "providers": [
29 | "Ichtrojan\\Location\\LocationServiceProvider"
30 | ]
31 | }
32 | },
33 | "require": {
34 | "illuminate/support": "^5.0 || ^6.0 || ^7.0 || ^8.0"
35 | },
36 | "require-dev": {
37 | "mockery/mockery": "^1.0",
38 | "orchestra/testbench": "3.8.*|4.*",
39 | "phpunit/phpunit": "^8.0",
40 | "illuminate/contracts": "^5.8.15|^6.0",
41 | "illuminate/filesystem": "^5.8.15|^6.0",
42 | "illuminate/support": "^5.8.15|^6.0",
43 | "illuminate/database": "^5.8.15|^6.0",
44 | "phpunit/php-code-coverage": "^7.0@dev"
45 | },
46 | "description": ""
47 | }
48 |
--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 | tests
15 |
16 |
17 |
18 |
19 | src/
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/publishable/config/location.php:
--------------------------------------------------------------------------------
1 | 'countries',
5 | 'cities_table' => 'cities',
6 | 'states_table' => 'states',
7 | 'routes' => [
8 | 'prefix' => 'location',
9 | 'middleware' => 'web'
10 | ]
11 | ];
12 |
--------------------------------------------------------------------------------
/src/Http/Controllers/Controller.php:
--------------------------------------------------------------------------------
1 | json($countries, 200);
17 | }
18 |
19 | /**
20 | * @param $id
21 | * @return JsonResponse
22 | */
23 | public function getCountry($id) {
24 | $country = Country::where('id', $id)->get(['id', 'code', 'name', 'phonecode']);
25 | return response()->json($country,200);
26 | }
27 |
28 | /**
29 | * @return JsonResponse
30 | */
31 | public function getStates() {
32 | $states = State::get(['id', 'name', 'country_id']);
33 | return response()->json($states, 200);
34 | }
35 |
36 | /**
37 | * @param $id
38 | * @return JsonResponse
39 | */
40 | public function getState($id) {
41 | $states = State::where('id', $id)->get(['id', 'name', 'country_id']);
42 | return response()->json($states, 200);
43 | }
44 |
45 | /**
46 | * @return JsonResponse
47 | */
48 | public function getCities() {
49 | $cities = City::get(['id', 'name', 'state_id']);
50 | return response()->json($cities, 200);
51 | }
52 |
53 | /**
54 | * @param $id
55 | * @return JsonResponse
56 | */
57 | public function getCity($id) {
58 | $country = City::where('id', $id)->get(['id', 'name', 'state_id']);
59 | return response()->json($country, 200);
60 | }
61 |
62 | /**
63 | * @param $countryId
64 | * @return JsonResponse
65 | */
66 | public function getStatesByCountry($countryId) {
67 | $countryStates = State::where('country_id', $countryId)->get(['id', 'name']);
68 | return response()->json($countryStates, 200);
69 | }
70 |
71 | /**
72 | * @param $stateId
73 | * @return JsonResponse
74 | */
75 | public function getCitiesByStates($stateId) {
76 | $stateCities = City::where('state_id', $stateId)->get(['id', 'name']);
77 | return response()->json($stateCities, 200);
78 | }
79 |
80 | /**
81 | * @param $countryId
82 | * @return JsonResponse
83 | */
84 | public function getCitiesByCountry($countryId) {
85 | $countryCities = City::where('country_id', $countryId)->get(['id', 'name']);
86 |
87 | return response()->json($countryCities, 200);
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/LocationServiceProvider.php:
--------------------------------------------------------------------------------
1 | app->make('Ichtrojan\Location\Http\Controllers\LocationController');
17 | $this->app->make('Ichtrojan\Location\Seeds\LocationDatabaseSeeder');
18 | $this->mergeConfigFrom(__DIR__ . "/../publishable/config/location.php", 'laravel-location');
19 | }
20 |
21 | /**
22 | * Bootstrap any application services.
23 | *
24 | * @return void
25 | */
26 | public function boot()
27 | {
28 | $this->loadRoutesFrom(__DIR__.'/routes/web.php');
29 | $this->loadMigrationsFrom(__DIR__.'/database/migrations');
30 |
31 | if ($this->app->runningInConsole()) {
32 | $this->publishConfigs();
33 | }
34 | }
35 |
36 | protected function publishConfigs()
37 | {
38 | $this->publishes([
39 | __DIR__ . "/../publishable/config/location.php" => config_path('location.php'),
40 | ], 'laravel-location');
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/Models/City.php:
--------------------------------------------------------------------------------
1 | table);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Models/Country.php:
--------------------------------------------------------------------------------
1 | table);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Models/State.php:
--------------------------------------------------------------------------------
1 | table);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/database/migrations/2019_05_11_000000_create_cities_table.php:
--------------------------------------------------------------------------------
1 | getTableName(), function (Blueprint $table) {
18 | $table->increments('id')->index();
19 | $table->string('name');
20 | $table->integer('state_id');
21 | $table->timestamps();
22 | });
23 | }
24 |
25 | protected function getTableName()
26 | {
27 | return Config::get('location.cities_table');
28 | }
29 |
30 | /**
31 | * Reverse the migrations.
32 | *
33 | * @return void
34 | */
35 | public function down()
36 | {
37 | Schema::dropIfExists($this->getTableName());
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/database/migrations/2019_05_11_000000_create_countries_table.php:
--------------------------------------------------------------------------------
1 | getTableName(), function (Blueprint $table) {
18 | $table->increments('id')->index();
19 | $table->string('code');
20 | $table->string('name');
21 | $table->integer('phonecode');
22 | $table->timestamps();
23 | });
24 | }
25 |
26 | protected function getTableName()
27 | {
28 | return Config::get('location.countries_table');
29 | }
30 |
31 | /**
32 | * Reverse the migrations.
33 | *
34 | * @return void
35 | */
36 | public function down()
37 | {
38 | Schema::dropIfExists($this->getTableName());
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/database/migrations/2019_05_11_000000_create_states_table.php:
--------------------------------------------------------------------------------
1 | getTableName(), function (Blueprint $table) {
18 | $table->increments('id')->index();
19 | $table->string('name');
20 | $table->integer('country_id');
21 | $table->timestamps();
22 | });
23 | }
24 |
25 | protected function getTableName()
26 | {
27 | return Config::get('location.states_table');
28 | }
29 |
30 | /**
31 | * Reverse the migrations.
32 | *
33 | * @return void
34 | */
35 | public function down()
36 | {
37 | Schema::dropIfExists($this->getTableName());
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/database/migrations/2019_12_01_000000_add_country_id_column_to_cities_table.php:
--------------------------------------------------------------------------------
1 | getTableName(), function (Blueprint $table) {
14 | if(!Schema::hasColumn($this->getTableName(), 'country_id'))
15 | $table->integer('country_id')->nullable();
16 | });
17 | }
18 |
19 | public function down()
20 | {
21 | Schema::table($this->getTableName(), function (Blueprint $table) {
22 | if(Schema::hasColumn($this->getTableName(), 'country_id'))
23 | $table->dropColumn('country_id');
24 | });
25 | }
26 |
27 | protected function getTableName()
28 | {
29 | return Config::get('location.cities_table');
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/database/seeds/CountriesTableSeeder.php:
--------------------------------------------------------------------------------
1 | 1,'code' => 'AF' ,'name' => "Afghanistan",'phonecode' => 93),
20 | array('id' => 2,'code' => 'AL' ,'name' => "Albania",'phonecode' => 355),
21 | array('id' => 3,'code' => 'DZ' ,'name' => "Algeria",'phonecode' => 213),
22 | array('id' => 4,'code' => 'AS' ,'name' => "American Samoa",'phonecode' => 1684),
23 | array('id' => 5,'code' => 'AD' ,'name' => "Andorra",'phonecode' => 376),
24 | array('id' => 6,'code' => 'AO' ,'name' => "Angola",'phonecode' => 244),
25 | array('id' => 7,'code' => 'AI' ,'name' => "Anguilla",'phonecode' => 1264),
26 | array('id' => 8,'code' => 'AQ' ,'name' => "Antarctica",'phonecode' => 0),
27 | array('id' => 9,'code' => 'AG' ,'name' => "Antigua And Barbuda",'phonecode' => 1268),
28 | array('id' => 10,'code' => 'AR','name' => "Argentina",'phonecode' => 54),
29 | array('id' => 11,'code' => 'AM','name' => "Armenia",'phonecode' => 374),
30 | array('id' => 12,'code' => 'AW','name' => "Aruba",'phonecode' => 297),
31 | array('id' => 13,'code' => 'AU','name' => "Australia",'phonecode' => 61),
32 | array('id' => 14,'code' => 'AT','name' => "Austria",'phonecode' => 43),
33 | array('id' => 15,'code' => 'AZ','name' => "Azerbaijan",'phonecode' => 994),
34 | array('id' => 16,'code' => 'BS','name' => "Bahamas The",'phonecode' => 1242),
35 | array('id' => 17,'code' => 'BH','name' => "Bahrain",'phonecode' => 973),
36 | array('id' => 18,'code' => 'BD','name' => "Bangladesh",'phonecode' => 880),
37 | array('id' => 19,'code' => 'BB','name' => "Barbados",'phonecode' => 1246),
38 | array('id' => 20,'code' => 'BY','name' => "Belarus",'phonecode' => 375),
39 | array('id' => 21,'code' => 'BE','name' => "Belgium",'phonecode' => 32),
40 | array('id' => 22,'code' => 'BZ','name' => "Belize",'phonecode' => 501),
41 | array('id' => 23,'code' => 'BJ','name' => "Benin",'phonecode' => 229),
42 | array('id' => 24,'code' => 'BM','name' => "Bermuda",'phonecode' => 1441),
43 | array('id' => 25,'code' => 'BT','name' => "Bhutan",'phonecode' => 975),
44 | array('id' => 26,'code' => 'BO','name' => "Bolivia",'phonecode' => 591),
45 | array('id' => 27,'code' => 'BA','name' => "Bosnia and Herzegovina",'phonecode' => 387),
46 | array('id' => 28,'code' => 'BW','name' => "Botswana",'phonecode' => 267),
47 | array('id' => 29,'code' => 'BV','name' => "Bouvet Island",'phonecode' => 0),
48 | array('id' => 30,'code' => 'BR','name' => "Brazil",'phonecode' => 55),
49 | array('id' => 31,'code' => 'IO','name' => "British Indian Ocean Territory",'phonecode' => 246),
50 | array('id' => 32,'code' => 'BN','name' => "Brunei",'phonecode' => 673),
51 | array('id' => 33,'code' => 'BG','name' => "Bulgaria",'phonecode' => 359),
52 | array('id' => 34,'code' => 'BF','name' => "Burkina Faso",'phonecode' => 226),
53 | array('id' => 35,'code' => 'BI','name' => "Burundi",'phonecode' => 257),
54 | array('id' => 36,'code' => 'KH','name' => "Cambodia",'phonecode' => 855),
55 | array('id' => 37,'code' => 'CM','name' => "Cameroon",'phonecode' => 237),
56 | array('id' => 38,'code' => 'CA','name' => "Canada",'phonecode' => 1),
57 | array('id' => 39,'code' => 'CV','name' => "Cape Verde",'phonecode' => 238),
58 | array('id' => 40,'code' => 'KY','name' => "Cayman Islands",'phonecode' => 1345),
59 | array('id' => 41,'code' => 'CF','name' => "Central African Republic",'phonecode' => 236),
60 | array('id' => 42,'code' => 'TD','name' => "Chad",'phonecode' => 235),
61 | array('id' => 43,'code' => 'CL','name' => "Chile",'phonecode' => 56),
62 | array('id' => 44,'code' => 'CN','name' => "China",'phonecode' => 86),
63 | array('id' => 45,'code' => 'CX','name' => "Christmas Island",'phonecode' => 61),
64 | array('id' => 46,'code' => 'CC','name' => "Cocos (Keeling) Islands",'phonecode' => 672),
65 | array('id' => 47,'code' => 'CO','name' => "Colombia",'phonecode' => 57),
66 | array('id' => 48,'code' => 'KM','name' => "Comoros",'phonecode' => 269),
67 | array('id' => 49,'code' => 'CG','name' => "Congo",'phonecode' => 242),
68 | array('id' => 50,'code' => 'CD','name' => "Congo The Democratic Republic Of The",'phonecode' => 242),
69 | array('id' => 51,'code' => 'CK','name' => "Cook Islands",'phonecode' => 682),
70 | array('id' => 52,'code' => 'CR','name' => "Costa Rica",'phonecode' => 506),
71 | array('id' => 53,'code' => 'CI','name' => "Cote D Ivoire (Ivory Coast)",'phonecode' => 225),
72 | array('id' => 54,'code' => 'HR','name' => "Croatia (Hrvatska)",'phonecode' => 385),
73 | array('id' => 55,'code' => 'CU','name' => "Cuba",'phonecode' => 53),
74 | array('id' => 56,'code' => 'CY','name' => "Cyprus",'phonecode' => 357),
75 | array('id' => 57,'code' => 'CZ','name' => "Czech Republic",'phonecode' => 420),
76 | array('id' => 58,'code' => 'DK','name' => "Denmark",'phonecode' => 45),
77 | array('id' => 59,'code' => 'DJ','name' => "Djibouti",'phonecode' => 253),
78 | array('id' => 60,'code' => 'DM','name' => "Dominica",'phonecode' => 1767),
79 | array('id' => 61,'code' => 'DO','name' => "Dominican Republic",'phonecode' => 1809),
80 | array('id' => 62,'code' => 'TP','name' => "East Timor",'phonecode' => 670),
81 | array('id' => 63,'code' => 'EC','name' => "Ecuador",'phonecode' => 593),
82 | array('id' => 64,'code' => 'EG','name' => "Egypt",'phonecode' => 20),
83 | array('id' => 65,'code' => 'SV','name' => "El Salvador",'phonecode' => 503),
84 | array('id' => 66,'code' => 'GQ','name' => "Equatorial Guinea",'phonecode' => 240),
85 | array('id' => 67,'code' => 'ER','name' => "Eritrea",'phonecode' => 291),
86 | array('id' => 68,'code' => 'EE','name' => "Estonia",'phonecode' => 372),
87 | array('id' => 69,'code' => 'ET','name' => "Ethiopia",'phonecode' => 251),
88 | array('id' => 70,'code' => 'XA','name' => "External Territories of Australia",'phonecode' => 61),
89 | array('id' => 71,'code' => 'FK','name' => "Falkland Islands",'phonecode' => 500),
90 | array('id' => 72,'code' => 'FO','name' => "Faroe Islands",'phonecode' => 298),
91 | array('id' => 73,'code' => 'FJ','name' => "Fiji Islands",'phonecode' => 679),
92 | array('id' => 74,'code' => 'FI','name' => "Finland",'phonecode' => 358),
93 | array('id' => 75,'code' => 'FR','name' => "France",'phonecode' => 33),
94 | array('id' => 76,'code' => 'GF','name' => "French Guiana",'phonecode' => 594),
95 | array('id' => 77,'code' => 'PF','name' => "French Polynesia",'phonecode' => 689),
96 | array('id' => 78,'code' => 'TF','name' => "French Southern Territories",'phonecode' => 0),
97 | array('id' => 79,'code' => 'GA','name' => "Gabon",'phonecode' => 241),
98 | array('id' => 80,'code' => 'GM','name' => "Gambia The",'phonecode' => 220),
99 | array('id' => 81,'code' => 'GE','name' => "Georgia",'phonecode' => 995),
100 | array('id' => 82,'code' => 'DE','name' => "Germany",'phonecode' => 49),
101 | array('id' => 83,'code' => 'GH','name' => "Ghana",'phonecode' => 233),
102 | array('id' => 84,'code' => 'GI','name' => "Gibraltar",'phonecode' => 350),
103 | array('id' => 85,'code' => 'GR','name' => "Greece",'phonecode' => 30),
104 | array('id' => 86,'code' => 'GL','name' => "Greenland",'phonecode' => 299),
105 | array('id' => 87,'code' => 'GD','name' => "Grenada",'phonecode' => 1473),
106 | array('id' => 88,'code' => 'GP','name' => "Guadeloupe",'phonecode' => 590),
107 | array('id' => 89,'code' => 'GU','name' => "Guam",'phonecode' => 1671),
108 | array('id' => 90,'code' => 'GT','name' => "Guatemala",'phonecode' => 502),
109 | array('id' => 91,'code' => 'XU','name' => "Guernsey and Alderney",'phonecode' => 44),
110 | array('id' => 92,'code' => 'GN','name' => "Guinea",'phonecode' => 224),
111 | array('id' => 93,'code' => 'GW','name' => "Guinea-Bissau",'phonecode' => 245),
112 | array('id' => 94,'code' => 'GY','name' => "Guyana",'phonecode' => 592),
113 | array('id' => 95,'code' => 'HT','name' => "Haiti",'phonecode' => 509),
114 | array('id' => 96,'code' => 'HM','name' => "Heard and McDonald Islands",'phonecode' => 0),
115 | array('id' => 97,'code' => 'HN','name' => "Honduras",'phonecode' => 504),
116 | array('id' => 98,'code' => 'HK','name' => "Hong Kong S.A.R.",'phonecode' => 852),
117 | array('id' => 99,'code' => 'HU','name' => "Hungary",'phonecode' => 36),
118 | array('id' => 100,'code' => 'IS','name' => "Iceland",'phonecode' => 354),
119 | array('id' => 101,'code' => 'IN','name' => "India",'phonecode' => 91),
120 | array('id' => 102,'code' => 'ID','name' => "Indonesia",'phonecode' => 62),
121 | array('id' => 103,'code' => 'IR','name' => "Iran",'phonecode' => 98),
122 | array('id' => 104,'code' => 'IQ','name' => "Iraq",'phonecode' => 964),
123 | array('id' => 105,'code' => 'IE','name' => "Ireland",'phonecode' => 353),
124 | array('id' => 106,'code' => 'IL','name' => "Israel",'phonecode' => 972),
125 | array('id' => 107,'code' => 'IT','name' => "Italy",'phonecode' => 39),
126 | array('id' => 108,'code' => 'JM','name' => "Jamaica",'phonecode' => 1876),
127 | array('id' => 109,'code' => 'JP','name' => "Japan",'phonecode' => 81),
128 | array('id' => 110,'code' => 'XJ','name' => "Jersey",'phonecode' => 44),
129 | array('id' => 111,'code' => 'JO','name' => "Jordan",'phonecode' => 962),
130 | array('id' => 112,'code' => 'KZ','name' => "Kazakhstan",'phonecode' => 7),
131 | array('id' => 113,'code' => 'KE','name' => "Kenya",'phonecode' => 254),
132 | array('id' => 114,'code' => 'KI','name' => "Kiribati",'phonecode' => 686),
133 | array('id' => 115,'code' => 'KP','name' => "Korea North",'phonecode' => 850),
134 | array('id' => 116,'code' => 'KR','name' => "Korea South",'phonecode' => 82),
135 | array('id' => 117,'code' => 'KW','name' => "Kuwait",'phonecode' => 965),
136 | array('id' => 118,'code' => 'KG','name' => "Kyrgyzstan",'phonecode' => 996),
137 | array('id' => 119,'code' => 'LA','name' => "Laos",'phonecode' => 856),
138 | array('id' => 120,'code' => 'LV','name' => "Latvia",'phonecode' => 371),
139 | array('id' => 121,'code' => 'LB','name' => "Lebanon",'phonecode' => 961),
140 | array('id' => 122,'code' => 'LS','name' => "Lesotho",'phonecode' => 266),
141 | array('id' => 123,'code' => 'LR','name' => "Liberia",'phonecode' => 231),
142 | array('id' => 124,'code' => 'LY','name' => "Libya",'phonecode' => 218),
143 | array('id' => 125,'code' => 'LI','name' => "Liechtenstein",'phonecode' => 423),
144 | array('id' => 126,'code' => 'LT','name' => "Lithuania",'phonecode' => 370),
145 | array('id' => 127,'code' => 'LU','name' => "Luxembourg",'phonecode' => 352),
146 | array('id' => 128,'code' => 'MO','name' => "Macau S.A.R.",'phonecode' => 853),
147 | array('id' => 129,'code' => 'MK','name' => "Macedonia",'phonecode' => 389),
148 | array('id' => 130,'code' => 'MG','name' => "Madagascar",'phonecode' => 261),
149 | array('id' => 131,'code' => 'MW','name' => "Malawi",'phonecode' => 265),
150 | array('id' => 132,'code' => 'MY','name' => "Malaysia",'phonecode' => 60),
151 | array('id' => 133,'code' => 'MV','name' => "Maldives",'phonecode' => 960),
152 | array('id' => 134,'code' => 'ML','name' => "Mali",'phonecode' => 223),
153 | array('id' => 135,'code' => 'MT','name' => "Malta",'phonecode' => 356),
154 | array('id' => 136,'code' => 'XM','name' => "Man (Isle of)",'phonecode' => 44),
155 | array('id' => 137,'code' => 'MH','name' => "Marshall Islands",'phonecode' => 692),
156 | array('id' => 138,'code' => 'MQ','name' => "Martinique",'phonecode' => 596),
157 | array('id' => 139,'code' => 'MR','name' => "Mauritania",'phonecode' => 222),
158 | array('id' => 140,'code' => 'MU','name' => "Mauritius",'phonecode' => 230),
159 | array('id' => 141,'code' => 'YT','name' => "Mayotte",'phonecode' => 269),
160 | array('id' => 142,'code' => 'MX','name' => "Mexico",'phonecode' => 52),
161 | array('id' => 143,'code' => 'FM','name' => "Micronesia",'phonecode' => 691),
162 | array('id' => 144,'code' => 'MD','name' => "Moldova",'phonecode' => 373),
163 | array('id' => 145,'code' => 'MC','name' => "Monaco",'phonecode' => 377),
164 | array('id' => 146,'code' => 'MN','name' => "Mongolia",'phonecode' => 976),
165 | array('id' => 147,'code' => 'MS','name' => "Montserrat",'phonecode' => 1664),
166 | array('id' => 148,'code' => 'MA','name' => "Morocco",'phonecode' => 212),
167 | array('id' => 149,'code' => 'MZ','name' => "Mozambique",'phonecode' => 258),
168 | array('id' => 150,'code' => 'MM','name' => "Myanmar",'phonecode' => 95),
169 | array('id' => 151,'code' => 'NA','name' => "Namibia",'phonecode' => 264),
170 | array('id' => 152,'code' => 'NR','name' => "Nauru",'phonecode' => 674),
171 | array('id' => 153,'code' => 'NP','name' => "Nepal",'phonecode' => 977),
172 | array('id' => 154,'code' => 'AN','name' => "Netherlands Antilles",'phonecode' => 599),
173 | array('id' => 155,'code' => 'NL','name' => "Netherlands The",'phonecode' => 31),
174 | array('id' => 156,'code' => 'NC','name' => "New Caledonia",'phonecode' => 687),
175 | array('id' => 157,'code' => 'NZ','name' => "New Zealand",'phonecode' => 64),
176 | array('id' => 158,'code' => 'NI','name' => "Nicaragua",'phonecode' => 505),
177 | array('id' => 159,'code' => 'NE','name' => "Niger",'phonecode' => 227),
178 | array('id' => 160,'code' => 'NG','name' => "Nigeria",'phonecode' => 234),
179 | array('id' => 161,'code' => 'NU','name' => "Niue",'phonecode' => 683),
180 | array('id' => 162,'code' => 'NF','name' => "Norfolk Island",'phonecode' => 672),
181 | array('id' => 163,'code' => 'MP','name' => "Northern Mariana Islands",'phonecode' => 1670),
182 | array('id' => 164,'code' => 'NO','name' => "Norway",'phonecode' => 47),
183 | array('id' => 165,'code' => 'OM','name' => "Oman",'phonecode' => 968),
184 | array('id' => 166,'code' => 'PK','name' => "Pakistan",'phonecode' => 92),
185 | array('id' => 167,'code' => 'PW','name' => "Palau",'phonecode' => 680),
186 | array('id' => 168,'code' => 'PS','name' => "Palestinian Territory Occupied",'phonecode' => 970),
187 | array('id' => 169,'code' => 'PA','name' => "Panama",'phonecode' => 507),
188 | array('id' => 170,'code' => 'PG','name' => "Papua new Guinea",'phonecode' => 675),
189 | array('id' => 171,'code' => 'PY','name' => "Paraguay",'phonecode' => 595),
190 | array('id' => 172,'code' => 'PE','name' => "Peru",'phonecode' => 51),
191 | array('id' => 173,'code' => 'PH','name' => "Philippines",'phonecode' => 63),
192 | array('id' => 174,'code' => 'PN','name' => "Pitcairn Island",'phonecode' => 0),
193 | array('id' => 175,'code' => 'PL','name' => "Poland",'phonecode' => 48),
194 | array('id' => 176,'code' => 'PT','name' => "Portugal",'phonecode' => 351),
195 | array('id' => 177,'code' => 'PR','name' => "Puerto Rico",'phonecode' => 1787),
196 | array('id' => 178,'code' => 'QA','name' => "Qatar",'phonecode' => 974),
197 | array('id' => 179,'code' => 'RE','name' => "Reunion",'phonecode' => 262),
198 | array('id' => 180,'code' => 'RO','name' => "Romania",'phonecode' => 40),
199 | array('id' => 181,'code' => 'RU','name' => "Russia",'phonecode' => 70),
200 | array('id' => 182,'code' => 'RW','name' => "Rwanda",'phonecode' => 250),
201 | array('id' => 183,'code' => 'SH','name' => "Saint Helena",'phonecode' => 290),
202 | array('id' => 184,'code' => 'KN','name' => "Saint Kitts And Nevis",'phonecode' => 1869),
203 | array('id' => 185,'code' => 'LC','name' => "Saint Lucia",'phonecode' => 1758),
204 | array('id' => 186,'code' => 'PM','name' => "Saint Pierre and Miquelon",'phonecode' => 508),
205 | array('id' => 187,'code' => 'VC','name' => "Saint Vincent And The Grenadines",'phonecode' => 1784),
206 | array('id' => 188,'code' => 'WS','name' => "Samoa",'phonecode' => 684),
207 | array('id' => 189,'code' => 'SM','name' => "San Marino",'phonecode' => 378),
208 | array('id' => 190,'code' => 'ST','name' => "Sao Tome and Principe",'phonecode' => 239),
209 | array('id' => 191,'code' => 'SA','name' => "Saudi Arabia",'phonecode' => 966),
210 | array('id' => 192,'code' => 'SN','name' => "Senegal",'phonecode' => 221),
211 | array('id' => 193,'code' => 'RS','name' => "Serbia",'phonecode' => 381),
212 | array('id' => 194,'code' => 'SC','name' => "Seychelles",'phonecode' => 248),
213 | array('id' => 195,'code' => 'SL','name' => "Sierra Leone",'phonecode' => 232),
214 | array('id' => 196,'code' => 'SG','name' => "Singapore",'phonecode' => 65),
215 | array('id' => 197,'code' => 'SK','name' => "Slovakia",'phonecode' => 421),
216 | array('id' => 198,'code' => 'SI','name' => "Slovenia",'phonecode' => 386),
217 | array('id' => 199,'code' => 'XG','name' => "Smaller Territories of the UK",'phonecode' => 44),
218 | array('id' => 200,'code' => 'SB','name' => "Solomon Islands",'phonecode' => 677),
219 | array('id' => 201,'code' => 'SO','name' => "Somalia",'phonecode' => 252),
220 | array('id' => 202,'code' => 'ZA','name' => "South Africa",'phonecode' => 27),
221 | array('id' => 203,'code' => 'GS','name' => "South Georgia",'phonecode' => 0),
222 | array('id' => 204,'code' => 'SS','name' => "South Sudan",'phonecode' => 211),
223 | array('id' => 205,'code' => 'ES','name' => "Spain",'phonecode' => 34),
224 | array('id' => 206,'code' => 'LK','name' => "Sri Lanka",'phonecode' => 94),
225 | array('id' => 207,'code' => 'SD','name' => "Sudan",'phonecode' => 249),
226 | array('id' => 208,'code' => 'SR','name' => "Suriname",'phonecode' => 597),
227 | array('id' => 209,'code' => 'SJ','name' => "Svalbard And Jan Mayen Islands",'phonecode' => 47),
228 | array('id' => 210,'code' => 'SZ','name' => "Swaziland",'phonecode' => 268),
229 | array('id' => 211,'code' => 'SE','name' => "Sweden",'phonecode' => 46),
230 | array('id' => 212,'code' => 'CH','name' => "Switzerland",'phonecode' => 41),
231 | array('id' => 213,'code' => 'SY','name' => "Syria",'phonecode' => 963),
232 | array('id' => 214,'code' => 'TW','name' => "Taiwan",'phonecode' => 886),
233 | array('id' => 215,'code' => 'TJ','name' => "Tajikistan",'phonecode' => 992),
234 | array('id' => 216,'code' => 'TZ','name' => "Tanzania",'phonecode' => 255),
235 | array('id' => 217,'code' => 'TH','name' => "Thailand",'phonecode' => 66),
236 | array('id' => 218,'code' => 'TG','name' => "Togo",'phonecode' => 228),
237 | array('id' => 219,'code' => 'TK','name' => "Tokelau",'phonecode' => 690),
238 | array('id' => 220,'code' => 'TO','name' => "Tonga",'phonecode' => 676),
239 | array('id' => 221,'code' => 'TT','name' => "Trinidad And Tobago",'phonecode' => 1868),
240 | array('id' => 222,'code' => 'TN','name' => "Tunisia",'phonecode' => 216),
241 | array('id' => 223,'code' => 'TR','name' => "Turkey",'phonecode' => 90),
242 | array('id' => 224,'code' => 'TM','name' => "Turkmenistan",'phonecode' => 7370),
243 | array('id' => 225,'code' => 'TC','name' => "Turks And Caicos Islands",'phonecode' => 1649),
244 | array('id' => 226,'code' => 'TV','name' => "Tuvalu",'phonecode' => 688),
245 | array('id' => 227,'code' => 'UG','name' => "Uganda",'phonecode' => 256),
246 | array('id' => 228,'code' => 'UA','name' => "Ukraine",'phonecode' => 380),
247 | array('id' => 229,'code' => 'AE','name' => "United Arab Emirates",'phonecode' => 971),
248 | array('id' => 230,'code' => 'GB','name' => "United Kingdom",'phonecode' => 44),
249 | array('id' => 231,'code' => 'US','name' => "United States",'phonecode' => 1),
250 | array('id' => 232,'code' => 'UM','name' => "United States Minor Outlying Islands",'phonecode' => 1),
251 | array('id' => 233,'code' => 'UY','name' => "Uruguay",'phonecode' => 598),
252 | array('id' => 234,'code' => 'UZ','name' => "Uzbekistan",'phonecode' => 998),
253 | array('id' => 235,'code' => 'VU','name' => "Vanuatu",'phonecode' => 678),
254 | array('id' => 236,'code' => 'VA','name' => "Vatican City State (Holy See)",'phonecode' => 39),
255 | array('id' => 237,'code' => 'VE','name' => "Venezuela",'phonecode' => 58),
256 | array('id' => 238,'code' => 'VN','name' => "Vietnam",'phonecode' => 84),
257 | array('id' => 239,'code' => 'VG','name' => "Virgin Islands (British)",'phonecode' => 1284),
258 | array('id' => 240,'code' => 'VI','name' => "Virgin Islands (US)",'phonecode' => 1340),
259 | array('id' => 241,'code' => 'WF','name' => "Wallis And Futuna Islands",'phonecode' => 681),
260 | array('id' => 242,'code' => 'EH','name' => "Western Sahara",'phonecode' => 212),
261 | array('id' => 243,'code' => 'YE','name' => "Yemen",'phonecode' => 967),
262 | array('id' => 244,'code' => 'YU','name' => "Yugoslavia",'phonecode' => 38),
263 | array('id' => 245,'code' => 'ZM','name' => "Zambia",'phonecode' => 260),
264 | array('id' => 246,'code' => 'ZW','name' => "Zimbabwe",'phonecode' => 263),
265 | );
266 |
267 | // Fix for issue #29 https://github.com/ichtrojan/laravel-location/issues/29
268 | Schema::disableForeignKeyConstraints();
269 | DB::table($countriesTable)->truncate();
270 | Schema::enableForeignKeyConstraints();
271 | DB::table($countriesTable)->insert($countries);
272 | }
273 | }
274 |
--------------------------------------------------------------------------------
/src/database/seeds/LocationDatabaseSeeder.php:
--------------------------------------------------------------------------------
1 | call(CountriesTableSeeder::class);
17 | $this->call(StatesTableSeeder::class);
18 | $this->call(CitiesTableSeeder::class);
19 | $this->call(StateCityCountrySeeder::class);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/database/seeds/StateCityCountrySeeder.php:
--------------------------------------------------------------------------------
1 | orderBy('id')
17 | ->chunk(100, function ($cities) use ($citiesTable, $statesTable) {
18 | foreach ($cities as $city) {
19 | $state = DB::table($statesTable)->where('id', $city->state_id)->first();
20 | if ($state) {
21 | $countryId = $state->country_id;
22 | DB::table($citiesTable)->where('id', $city->id)->update([
23 | 'country_id' => $countryId,
24 | ]);
25 | }
26 | }
27 | });
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/routes/web.php:
--------------------------------------------------------------------------------
1 | Config::get('location.routes.prefix'), 'namespace' => 'Ichtrojan\Location\Http\Controllers', 'middleware' => [Config::get('location.routes.middleware')]], function () {
4 | # Get all Countries
5 | Route::get('countries', 'LocationController@getCountries');
6 |
7 | # Get a Country by its ID
8 | Route::get('country/{id}', 'LocationController@getCountry');
9 |
10 | # Get all States
11 | Route::get('states', 'LocationController@getStates');
12 |
13 | # Get a State by its ID
14 | Route::get('state/{id}', 'LocationController@getState');
15 |
16 | # Get all States in a Country using the Country ID
17 | Route::get('states/{countryId}', 'LocationController@getStatesByCountry');
18 |
19 | # Get all Cities
20 | Route::get('cities', 'LocationController@getCities');
21 |
22 | # Get a City by its ID
23 | Route::get('city/{id}', 'LocationController@getCity');
24 |
25 | # Get all Cities in a State using the State ID
26 | Route::get('cities/{stateId}', 'LocationController@getCitiesByStates');
27 |
28 | # Get all Cities in a Country using the Country ID
29 | Route::get('country-cities/{countryId}', 'LocationController@getCitiesByCountry');
30 | });
31 |
--------------------------------------------------------------------------------
/tests/LocationRouteTest.php:
--------------------------------------------------------------------------------
1 | get('location/countries');
19 | $response->assertStatus(200);
20 | $responseData = json_decode($response->getContent(), true);
21 | $this->assertTrue(count($responseData) == 246);
22 | }
23 |
24 | /** @test */
25 | public function it_can_access_country_by_id()
26 | {
27 | $response = $this->get('location/country/1');
28 | $response->assertStatus(200);
29 | $responseData = json_decode($response->getContent(), true);
30 | $firstCountry = [
31 | 'id' => 1,
32 | 'code' => 'AF',
33 | 'name' => 'Afghanistan',
34 | 'phonecode' => '93',
35 | ];
36 | $this->assertEquals($firstCountry, $responseData[0]);
37 | }
38 |
39 | /** @test */
40 | public function it_can_access_states_list()
41 | {
42 | $response = $this->get('location/states');
43 | $response->assertStatus(200);
44 | $responseData = json_decode($response->getContent(), true);
45 | $this->assertTrue(count($responseData) == 4121);
46 | }
47 |
48 | /** @test */
49 | public function it_can_access_state_by_id()
50 | {
51 | $response = $this->get('location/state/1');
52 | $response->assertStatus(200);
53 | $responseData = json_decode($response->getContent(), true);
54 | $firstCountry = [
55 | 'id' => 1,
56 | 'name' => "Andaman and Nicobar Islands",
57 | 'country_id' => 101
58 | ];
59 | $this->assertEquals($firstCountry, $responseData[0]);
60 | }
61 |
62 | /** @test */
63 | public function it_can_access_states_by_country()
64 | {
65 | $response = $this->get('location/states/1');
66 | $response->assertStatus(200);
67 | $responseData = json_decode($response->getContent(), true);
68 | $firstState = [
69 | 'name' => 'Badakhshan',
70 | 'id' => 42
71 | ];
72 |
73 | $this->assertEquals($firstState, $responseData[0]);
74 | }
75 |
76 | /** @test */
77 | public function it_can_access_cities_list()
78 | {
79 | $response = $this->get('location/cities');
80 | $response->assertStatus(200);
81 | $responseData = json_decode($response->getContent(), true);
82 |
83 | $this->assertTrue(count($responseData) == 48017);
84 | }
85 |
86 | /** @test */
87 | public function it_can_access_city_by_id()
88 | {
89 | $response = $this->get('location/city/1');
90 | $response->assertStatus(200);
91 | $responseData = json_decode($response->getContent(), true);
92 | $firstCity = [
93 | 'id' => 1,
94 | 'name' => "Bombuflat",
95 | 'state_id' => 1
96 | ];
97 | $this->assertEquals($firstCity, $responseData[0]);
98 | }
99 |
100 | /** @test */
101 | public function it_can_access_cities_by_state()
102 | {
103 | $response = $this->get('location/cities/1');
104 | $response->assertStatus(200);
105 | $responseData = json_decode($response->getContent(), true);
106 | $firstCity = [
107 | 'name' => 'Bombuflat',
108 | 'id' => 1
109 | ];
110 |
111 | $this->assertEquals($firstCity, $responseData[0]);
112 | }
113 |
114 | /** @test */
115 | public function it_can_access_cities_by_country()
116 | {
117 | $response = $this->get('location/country-cities/223');
118 | $response->assertStatus(200);
119 | $responseData = json_decode($response->getContent(), true);
120 |
121 | $firstCity = [
122 | 'name' => 'Adiyaman',
123 | 'id' => 40282
124 | ];
125 |
126 | $this->assertEquals($firstCity, $responseData[0]);
127 | }
128 |
129 | /** @test */
130 | public function test_all_states_have_country_id()
131 | {
132 | $count = State::query()
133 | ->whereNull('country_id')
134 | ->count();
135 |
136 | $this->assertEquals(0, $count);
137 | }
138 |
139 | /** @test */
140 | public function test_all_cities_have_country_id()
141 | {
142 | $count = City::query()
143 | ->whereNull('country_id')
144 | ->count();
145 |
146 | $this->assertEquals(0, $count);
147 | }
148 |
149 | /** @test */
150 | public function test_all_cities_have_state_id()
151 | {
152 | $count = City::query()
153 | ->whereNull('state_id')
154 | ->count();
155 |
156 | $this->assertEquals(0, $count);
157 | }
158 |
159 | }
160 |
161 |
--------------------------------------------------------------------------------
/tests/TestCase.php:
--------------------------------------------------------------------------------
1 | setUpDatabase();
22 |
23 | // Note: this also flushes the cache from within the migration
24 | }
25 |
26 | /**
27 | * @param \Illuminate\Foundation\Application $app
28 | *
29 | * @return array
30 | */
31 | protected function getPackageProviders($app)
32 | {
33 | return [
34 | LocationServiceProvider::class,
35 | ];
36 | }
37 |
38 | /**
39 | * Set up the environment.
40 | *
41 | * @param \Illuminate\Foundation\Application $app
42 | */
43 | protected function getEnvironmentSetUp($app)
44 | {
45 | $app['config']->set('database.default', 'sqlite');
46 | $app['config']->set('database.connections.sqlite', [
47 | 'driver' => 'sqlite',
48 | 'database' => ':memory:',
49 | 'prefix' => '',
50 | ]);
51 |
52 | $app['config']->set('app.key', 'base64:' . base64_encode(
53 | Encrypter::generateKey($app['config']['app.cipher'])
54 | ));
55 |
56 | $app['config']->set('location.states_table', 'states');
57 | $app['config']->set('location.cities_table', 'cities');
58 | $app['config']->set('location.countries_table', 'countries');
59 | $app['config']->set('location.routes.prefix', 'location');
60 | $app['config']->set('location.routes.middleware', 'web');
61 | }
62 |
63 | /**
64 | * Set up the database.
65 | *
66 | * @param \Illuminate\Foundation\Application $app
67 | */
68 | protected function setUpDatabase()
69 | {
70 | $this->createCountriesTable();
71 | $this->createStatesTable();
72 | $this->createCitiesTable();
73 | $this->addCountryColumnToCitiesTable();
74 | $this->seedCountriesTable();
75 | $this->seedStatesTable();
76 | $this->seedCitiesTable();
77 | $this->updateCitiesTable();
78 | }
79 |
80 | protected function createCountriesTable()
81 | {
82 | include_once __DIR__ . '/../src/database/migrations/2019_05_11_000000_create_countries_table.php';
83 | (new \CreateCountriesTable())->up();
84 | }
85 |
86 | protected function createStatesTable()
87 | {
88 | include_once __DIR__ . '/../src/database/migrations/2019_05_11_000000_create_states_table.php';
89 | (new \CreateStatesTable())->up();
90 | }
91 |
92 | protected function createCitiesTable()
93 | {
94 | include_once __DIR__ . '/../src/database/migrations/2019_05_11_000000_create_cities_table.php';
95 | (new \CreateCitiesTable())->up();
96 | }
97 |
98 | protected function addCountryColumnToCitiesTable()
99 | {
100 | include_once __DIR__ . '/../src/database/migrations/2019_12_01_000000_add_country_id_column_to_cities_table.php';
101 | (new \AddCountryIdColumnToCitiesTable())->up();
102 | }
103 |
104 | protected function seedCountriesTable()
105 | {
106 | (new CountriesTableSeeder())->run();
107 | }
108 |
109 | protected function seedStatesTable()
110 | {
111 | (new StatesTableSeeder())->run();
112 | }
113 |
114 | protected function seedCitiesTable()
115 | {
116 | (new CitiesTableSeeder())->run();
117 | }
118 |
119 | protected function updateCitiesTable()
120 | {
121 | (new StateCityCountrySeeder())->run();
122 | }
123 |
124 | }
125 |
--------------------------------------------------------------------------------