nnjeim / world

A Laravel package which provides a list of the countries, states, cities, currencies, timezones and languages.
MIT License
748 stars 105 forks source link

Italian Postal Code #38

Closed slamservice closed 1 year ago

slamservice commented 1 year ago

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

nnjeim commented 1 year ago

@slamservice all json files are located in the folder resources > json > cities a city object looks like


  {
        "id": 68,
        "name": "Fayzabad",
        "state_id": 3901,
        "state_code": "BDS",
        "country_id": 1,
        "country_code": "AF",
        "latitude": "37.11664000",
        "longitude": "70.58002000",
        "wikiDataId": "Q156558"
    },
slamservice commented 1 year ago

But where did you recover cities.json from? From Geonames? I must be able to extract cities.json with the postal code.

{
        "id": 68,
        "name": "Fayzabad",
        "state_id": 3901,
        "state_code": "BDS",
        "country_id": 1,
        "country_code": "AF",
        "latitude": "37.11664000",
        "longitude": "70.58002000",
        "wikiDataId": "Q156558",
        "postalCode": "20056"
    }
If I make a join table, how do I relate it to cities?
nnjeim commented 1 year ago

does a city have a unique postal code? if not it is not the ok to place the codes in the cities.json you need to link the tables with a foreign key : city_id (1 to many)

slamservice commented 1 year ago

Yes, unique postal code.

nnjeim commented 1 year ago

https://www.geonames.org/postal-codes/