nnjeim / world Goto Github PK
View Code? Open in Web Editor NEWA Laravel package which provides a list of the countries, states, cities, currencies, timezones and languages.
License: MIT License
A Laravel package which provides a list of the countries, states, cities, currencies, timezones and languages.
License: MIT License
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.
Describe the bug
I tried to add a custom language Serbian Latin and the code for that is sr_Latn, now that is not supported but I think it can be easily done in WorldServiceProvider. A temporary solution is to use sr but that is not good solution because in the future I should have a Serbian Cyrillic version
Hi,
As a huge enhancement, is it possible to add airports information with IATA code, etc, and link them to the cities in a future release?
Is your feature request related to a problem? Please describe.
I am integrating this package with a devops pipeline and an existing application.
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 :) !
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.
Could I suggest that for the country of Singapore we remove this 5 states:
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.
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.
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";
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
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))
Describe the bug
Czech and Croatian language codes are wrong in the file resources/json/languages.json.
Additional context
Czech code should be "cs" and Croatian code should be "hr" as listed in https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes.
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
I noticed that I couldn't select all countries
It returns an empty collection
I've seeded the database
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.
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):
I hope to add language packs for cities and streets in the future
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.
Describe the bug
Please check the issue. i can see the language in it
To Reproduce
just do a call to countries database
Expected behavior
Need to see country name
Screenshots
If applicable, add screenshots to help explain your problem.
The World::counries()->data returns empty
This happens even when i have run the migration and seeder
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?
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:
World::countries( [
"fields" => "iso2,name"
"filters" => [
"iso2" => "XK"
]
]);
Expected behavior
When fetching the country with iso2 XK we should get:
[
"id" => 116,
"iso2" => "XK",
"name" => "Kosovo",
]
Hi, I wanted to know which was the best way to:
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
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?
Thank you 😄
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.
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
croatia currency should be euro
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
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
Hi, I need to add postal code to cities: where do you generate cities.json from?
Thanks.
Marco
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?
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?
Running the seeder command php artisan db:seed --class=WorldSeeder does nothing. The Countries and States don't get to populate any record in the database.
Kindly assist.. Thank you
Dear,
Thank you for your effort
the seeding command does not add any data to the tables
please advise
Thank you
Any chance to add continents and locales/translations.
When trying to seed the entire package contents it breaks and no error is shown.
Steps to reproduce the behaviour:
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:
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.
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behaviour:
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):
Smartphone (please complete the following information):
Additional context
I tried truncating tables, Still no luck.
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?
When trying to seed the database, it is causing error like Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes)
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!
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
Think about adding limit parameter to your API points or maybe I cant find how to add limit?
The seeder is nit adding any data
Is your feature request related to a problem? Please describe.
No
Describe the solution you'd like
Sometimes we may need only some countries for our application, so no need to insert the whole World DB, and later we may append other countries
Thanks
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"
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
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", },
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 ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.