GithubHelp home page GithubHelp logo

nnjeim / world Goto Github PK

View Code? Open in Web Editor NEW
710.0 710.0 91.0 7.05 MB

A Laravel package which provides a list of the countries, states, cities, currencies, timezones and languages.

License: MIT License

PHP 100.00%
cities countries countries-api country currencies language languages laravel laravel-package states timezones

world's People

Contributors

ades4827 avatar aeq-dev avatar cloudchristoph avatar emiliopedrollo avatar gdevlugt avatar ivanshamir avatar marc31 avatar mbanusic avatar mefenlon avatar mrmmg avatar nnjeim avatar parth391 avatar rinodrummer avatar waadmawlood avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

world's Issues

Question about the SeedAction

Is there a reason that you removed the fields before you seeded the database?

$this->forgetFields($countryFields, ['id']);

I find this completed redundant since the ids in the json resource match already.

Migrations and seeding for devops pipeline

Is your feature request related to a problem? Please describe.
I am integrating this package with a devops pipeline and an existing application.

  • The migrations are not published so I cannot change the order (modifying their timestamps) and they are applied after my migrations so I cannot add in my migrations the foreignId to the countries table as it is migrated later.
  • In my the devops pipeline I am migrating and seeding the database before running tests, and to speed up the tests I like to seed just some countries/cities/states.... and not the the full dataset.

Describe the solution you'd like
I would like to change the migration order so this package is applied before my migrations, for that if possible it will be great if migrations are published so they timestamp can be modified, I do not know if this affects the package upgrades in the future.
It would be nice if the seed operation allows config option to allow partial or full seeding, so full can be perform just once and partial (much faster) can be used in testing for some records.

Describe alternatives you've considered
I have checked that there is a migrations --package flag that could force the migration of a package but it only exists for newer laravel versions and I also prefer to keep the devops pipeline clean without code for this package.
Regarding the seeding for the testing, I have consider creating a custom countries/states... small seed so my tests start faster and still I have some data (not all) to check the relevant relations, but it will be more coherente to use the existing dataset instead of making up some new ones.

Additional context
Thanks for this package :) !

Laravel 10 - lang directory location is changed

Describe the bug
After installing a package my localization stopped working and I couldn't find what's the problem. After a few hours, I saw what is the problem, this package overridden the complete location for reading localization and after moving my files to resources/lang started working again but that is not a good solution please fix the bug so we can keep the lang directory in the root because other packages trying to load localization from original location.

Remove states of Singapore

Could I suggest that for the country of Singapore we remove this 5 states:

  • Central Singapore Community Development Council
  • North East Community Development Council
  • North West Community Development Council
  • South East Community Development Council
  • South West Community Development Council

https://github.com/nnjeim/world/blob/master/resources/json/states.json#L39207

Reason: Singapore is tiny (smaller then New York City) and is itself a city-state. So strictly speaking Singapore has no states.

On-demand country name localization

A good thing would be to make country names only available in english by default and make extras installable via a command world:install-locale tr_TR which will automatically pull the country data from https://github.com/umpirsky/country-list/blob/master/data/tr_TR/country.php and save it to the lang/vendor folder.

Redundant country_code in states tables

It isn't necessary to denormalise the states table.
The country_code attribute already exists as the country.iso2 column and can be easily extracted with following SQL query

select * from countries join states on countries.id = states.country_id where countries.iso2 <> "AF";

On db:seed truncate problem with foreignId on models

Describe the bug
If you create a model and have a foreignId in a for example countries id, when try to db:seed and error about truncate happend.

To Reproduce
Create a model with a foreignId
$table->foreignId('country_id')->references('id')->on('countries');

php artisan db:seed --class=WorldSeeder

** Error **

Syntax error or access violation: 1701 Cannot truncate a table referenced in a foreign key constraint (fer.taxes, CONSTRAINT taxes_country_id_foreign FOREIGN KEY (country_id) REFERENCES fer.countries (id)) (SQL: truncate table countries)

** Possible solution **

Schema::disableForeignKeyConstraints(); <- before truncate
Schema::enableForeignKeyConstraints(); <- after truncate

Seeder error: Column 'native' cannot be null

The database seeder returns a critical error on native column for table countries.

To reproduce is enough to set as required the native field under migrations block in the configuration file (migrations->countries->optional_fields->nativa) and then run the seeder with artisan command php artisan world:refresh

This is the error it gives:
Integrity constraint violation: 1048 Column 'native' cannot be null (Connection: mysql, SQL: insert into countries (name, iso3, iso2, phone_code, native, region, subregion) values (Cote D'Ivoire (Ivory Coast), CIV, CI, 225, ?, Africa, Western Africa))

Create extra cities or states which are missing

Is your feature request related to a problem? Please describe.
There are some missing cities in some countries which it would be great to be added

Describe the solution you'd like
Create cities or states through a method

Some city strings are malformed

While exploring your package I came across this anomaly - there is no space between words in data on the database tables.
All country, state, and city names are like this.

Database query (db:seed) took too long

Describe the bug
I installed and configured the package as described in the documentation, and everything seems to be working properly. However, I've noticed that the queries are taking a long time to execute. For example, the seed operation takes 25,087,113 ms, which is much too high.

Upon checking the MySQL process while the seed operation is running, I found that the package is creating cities for each country using single insert queries instead of bulk queries. This means that the package is running approximately 150,000 insert queries, which corresponds to the number of rows in the city table.

To improve performance, I suggest modifying the package to use bulk insert queries instead of single insert queries when creating cities. This should significantly reduce the number of queries executed and improve the overall performance of the package.

To Reproduce
I describe the problem above.

Desktop (please complete the following information):

  • OS: Linux Ubuntu 20.04
  • PHP: 8.0 With memory_limit 2048M
  • MySQL: 8
  • Project running of Ubuntu container with PHP (no official image) and the database is in another container

Disable routes

Is your feature request related to a problem? Please describe.
I want to have my routes controlled. And not have not need routed.

Describe the solution you'd like
A possibility to disable routes that create package from config file.

Empty data response

The World::counries()->data returns empty
This happens even when i have run the migration and seeder

Possible to run database migrations on tenant?

Hi! We do have a multitenancy app and I would like to run this package on the tenant. For this I will need to run migrations and seeders on the tenants but I do not see an option to config this. Possible solution or is this something which could be added?

Missing country language entry for XK (Kosovo)

Describe the bug
When fetching the country with iso2 XK we get a missing name:

[
    "id" => 116,
    "iso2" => "XK",
    "name" => "world::country.XK",
]

To Reproduce
Steps to reproduce the behavior:

  1. call:
World::countries( [ 
  "fields" => "iso2,name"
  "filters" => [
    "iso2" => "XK"
  ]
]);
  1. See the missing county name in the result.

Expected behavior
When fetching the country with iso2 XK we should get:

[
    "id" => 116,
    "iso2" => "XK",
    "name" => "Kosovo",
]

Best way

Hi, I wanted to know which was the best way to:

  1. create the italian translation
  2. add the post code field to the Italian cities
    Thanks.
    Marco

Missing Main Italian Provinces

Is your feature request related to a problem? Please describe.
There are some Italian provinces missing: its major cities like Rome, Naples, Milan, Turin and more (which are metropolitan cities and also provinces at the same time)

Describe the solution you'd like
I wanted to add them to the states json but then I thought: should I add the native name "Napoli" or english "Naples" or both

I think we should add the native name field also to cities and states, like you did in countries because for example I found both Naples and Napoli in cities which is referred to the same city and it doesn't have sense when you load the whole list in a select menu

Publishing Command Doesn't Publish the Migration Files

Describe the bug
When I executed the command php artisan vendor:publish --tag=world I got this message

Copied File [/vendor/nnjeim/world/config/world.php] To [/config/world.php]
Copied File [/vendor/nnjeim/world/src/Database/Seeders/WorldSeeder.php] To [/database/seeders/WorldSeeder.php]
Copied Directory [/vendor/nnjeim/world/resources/lang] To [/resources/lang/vendor/world]
Publishing complete.

As you can see, no migration files have been published. I don't know if it's a bug or do you store the data in a json file or do they generate when you execute the seed file, can you please explain? because what I found in the readme is that there are tables, but I can't find any when publishing the files.

Expected behavior
publishing the migration files?

Screenshots
Screen Shot 2022-03-05 at 13 33 35

Thank you 😄

Rename regions attribute to continents.

It is more deductive to rename the column countries.region to countries.continent.
The country.subregion does make generic sense and can be kept as it is.

Set prefix for migration tables

Is your feature request related to a problem? Please describe.
May be there's an existing table with same table name

Describe the solution you'd like
Just put a config prefix field and update migration files according to this

Describe alternatives you've considered
This should be done before migration

Additional context
Thanks

cannot migrate on first install

hi i just stated to download package and do install
iam still on laravel 8
i got this message

php artisan migrate
Migrating: 2020_07_07_055656_create_countries_table

ErrorException

foreach() argument must be of type array|object, null given

at vendor/nnjeim/world/src/Database/Migrations/2020_07_07_055656_create_countries_table.php:22
18▕ $table->string('iso2', 2);
19▕ $table->string('name');
20▕ $table->tinyInteger('status')->default(1);
21▕
➜ 22▕ foreach (config('world.migrations.countries.optional_fields') as $field => $value) {
23▕ if ($value['required']) {
24▕ $table->string($field, $value['length'] ?? null);
25▕ }
26▕ }

  +27 vendor frames 

28 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

Process finished with exit code 1.

this might be related to the other issue today - please have a look

I cant see the states in states call

HI

i am trying to do this call

$action = World::states([ 'filters' => [ 'country_id' => 168 ] ]);

it's not given me the states for that country just giving me cities but if i change the filter to ios2 it will give me data. but problem is that in database i am storing country id any idea why its doing like that

Italian Postal Code

Hi, I need to add postal code to cities: where do you generate cities.json from?
Thanks.
Marco

Include specific field in response

Hey, i have the following scenario:
I should have a way to search cities by name and return the cities along with their country and state code:
Here is my action:

$action = World::cities([
            'fields' => 'country,state',
            'search' => $request->get('query')
        ]);

As a result, I'm not receiving the state code but only the state id and state name. Is there any way to preload the states with the state_code?

Contribute to the project

I want to contribute to the project. I've some implementations that I want to share.

First of all, the origin of the data, I think that you get the data from https://www.geonames.org/, is correct?

I've some projects where I use geonames, I know its database structure very well.

I'd like to add to your world project more admin levels, including more villages, not only cities.

I also have support for coordinates and geospatial searches, nearest cities from x for example.

Are you interested in these features?

Seed not working

Dear,
Thank you for your effort
the seeding command does not add any data to the tables
please advise
Thank you

Seed create multiple same currency

Describe the bug
Then seed the DB in the currency table creating multiple of the same currency.

To Reproduce
Steps to reproduce the behavior:

  1. php artisan db:seed --class=WorldSeeder

Screenshots
image

I am unable to seed the package.

When trying to seed the entire package contents it breaks and no error is shown.

Steps to reproduce the behaviour:

  1. Full migrate:fresh of DB
  2. Seed WorldSeeder

I expect the contents to be seeded to the DB, but nothing seeds from this package. The other seeders I have worked as expected.

Software:

  • OS: MacOS M2
  • Laravel 10.10

Continents

Is your feature request related to a problem? Please describe.
Would be useful to grab the continent of a specific country for various of reasons.

Describe the solution you'd like
Be able to get the continent of a country.

Stuck at 40%, I see some countries are not seeded.

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behaviour:

  1. Go to 'Terminal'
  2. Click on 'Run db:seed'
  3. After waiting for 2 minutes
  4. See error 'Stuck at 40%, I see some countries are not seeded.'

Seeding start

101/250 [▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░] 40%

Expected behaviour
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. MacBook]
  • OS: [e.g. MacOS Monterey]
  • Terminal [e.g. iTerm2]
  • Version [e.g. laravel 9]

Additional context
I tried truncating tables, Still no luck.

Cities Table is not seeding

Laravel Version: 8.65
Nnjeim/world: ^1.0

While using php artisan db:seed --class="WorldSeeder", it takes less than expected which means, nothing was seeded. However, I've found that after comment the line 30, the seed works without cities table.
line 30:
$this->data['cities'] = json_decode(File::get(__DIR__ . '/../../resources/json/cities.json'), true);
I was thinking that the file cities.json is very big. But, changing configurations in php.ini, such as upload_max_filesize and post_max_size to greater than the size of the file still not working.
What should I do to make the seed works?

Please state where you are getting the data from

I'm trying to determine what the data source for this package is.

Could you please tell me where this data is sourced from?
Consider also putting this information on the README.md

Thank you!

Lang directory path changed

when i run
php artisan vendor:publish --tag=world
the lang directory goes under resources but after laravel 9 it should be in the root
this make bug of all trans or __() not working unless i deleted resources/lang

States Abbreviations

I use your package to select user location and search countries by their iso2 or iso3. i think if states had some kind of abbreviations field in the states table it would be useful. for example "ny" for "new york" or "ca" for "california"

Adding additional cities/states to cities.json and states.json

Cannot edit cities.json or states.json or reupload files on my fork and submit a pull request due to the size of both files. Our org is using this package for a project and need to add a few cities/states that are in our db seem to be missing from cities.json:

Singapore*, Asunción*, İstanbul, Arendal, St. Gallen, Chambost-Allières, Ceuta*, Fort-de-France

  • these cities are city/states that are also missing from states.json

See the suggested additions below, without ids/codes where applicable:

cities.json:
{ "id": null, //needs to be generated "name": "Singapore", "state_id": null, //needs to be generated after state created "state_code": "null", //needs to be generated after state created "state_name": "Singapore", "country_id": 199, "country_code": "SG", "country_name": "Singapore", "latitude": "1.283333", "longitude": "103.833333, "wikiDataId": "Q334" }, { "id": null, //needs to be generated "name": "Asunción", "state_id": null, //needs to be generated after state created "state_code": "null", //needs to be generated after state created "state_name": "Singapore", "country_id": 172, "country_code": "PY", "country_name": "Paraguay", "latitude": "-25.3", "longitude": "-57.633333", "wikiDataId": "Q2933" }, { "id": null, //needs to be generated "name": "İstanbul", "state_id": 2170, "state_code": "34", "state_name": "İstanbul", "country_id": 225, "country_code": "TR", "country_name": "Turkey", "latitude": "41.16343020", "longitude": "28.76644080", "wikiDataId": "Q406" }, { "id": null, //needs to be generated "name": "Arendal", "state_id": 1014, "state_code": "42", "state_name": "Agder", "country_id": 165, "country_code": "NO", "country_name": "Norway", "latitude": "58.4612", "longitude": "8.7669", "wikiDataId": "Q2699921" }, { "id": null, //needs to be generated "name": "St. Gallen", "state_id": 1644, "state_code": "SG", "state_name": "St. Gallen", "country_id": 214, "country_code": "CH", "country_name": "Switzerland", "latitude": "47.424167", "longitude": "9.370833", "wikiDataId": "Q25607" }, { "id": null, //needs to be generated "name": "Chambost-Allières", "state_id": 5037, "state_code": "69", "state_name": "Rhône", "country_id": 75, "country_code": "FR", "country_name": "France", "latitude": "46.0192", "longitude": "4.4992" "wikiDataId": "Q2026" }, { "id": null, //needs to be generated "name": "Ceuta", "state_id": null, //needs to be generated after state created "state_code": "null", //needs to be generated after state created "state_name": "Ceuta", "country_id": 207, "country_code": "ES", "country_name": "Spain", "latitude": "35.888333", "longitude": "-5.315556", "wikiDataId": "Q5823" }, { "id": null, //needs to be generated "name": "Fort-de-France", "state_id": 4827, "state_code": "972", "state_name": "Martinique", "country_id": 75, "country_code": "FR", "country_name": "France", "latitude": "14.6, "longitude": "-61.066667", "wikiDataId": "Q81621" },

states.json
{ "id": null, //needs to be generated "name": "Singapore", "country_id": 199, "country_code": "SG", "country_name": "Singapore", "state_code": "01", "type": null, "latitude": "1.283333", "longitude": "103.833333" }, { "id": null, //needs to be generated "name": "Asunción", "country_id": 172, "country_code": "PY", "country_name": "Paraguay", "state_code": "null", //needs to be generated after state created "type": null, "latitude": "-25.3"", "longitude": "-57.633333" }, { "id": null, //needs to be generated "name": "Ceuta", "country_id": 207, "country_code": "ES", "country_name": "Spain", "state_code": "null", //needs to be generated after state created "type": null, "latitude": "35.888333", "longitude": "-5.315556", },

Incomplete database structure

When I see your JSON resource files, you have many informations that are not present in the database structure. For example in the countries.json you have missing data like numeric_code, tld, languages, emoji. Same for timezone table which lack of information, also states

Is there any update you are working on ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.