PHPackages                             zinapse/laralocate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. zinapse/laralocate

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

zinapse/laralocate
==================

Get information about various locations, countries, states, cities, etc.

v1.0.5(3y ago)072MITPHPPHP &gt;=8.0

Since Apr 17Pushed 3y ago1 watchersCompare

[ Source](https://github.com/zinapse/laralocate)[ Packagist](https://packagist.org/packages/zinapse/laralocate)[ Docs](https://github.com/zinapse/laralocate)[ RSS](/packages/zinapse-laralocate/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

zinapse/laralocate
==================

[](#zinapselaralocate)

Get relationships between countries, states, and cities.

Overview
--------

[](#overview)

This package grabs a JSON file containing data for locations around the world, then parses that data into a database. [That file is here.](https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/54939ff65f80369ba8b78e5277b5ed2ed503ef50/countries%2Bstates%2Bcities.json)

Installation
------------

[](#installation)

1. Include it with composer: `composer require zinapse/laralocate`
2. Make sure you run the migrations: `php artisan migrate`

    - You can see what changes will be made first using **--pretend**: `php artisan migrate --pretend`.
3. After that all you need to do is populate the database: `php artisan laralocate:populate`

    - You can use the `--cities` option to see verbose city output.
    - If you don't want the command to download the JSON file automatically, you can specify your own JSON file's path: `php artisan laralocate:populate --file=/my/path/to/file.json` (just make sure it follows the same structure)

Models
======

[](#models)

City
----

[](#city)

A City object has a name, and a state ID as a parent.

Column NameDatanamestringstate\_idforeign key```
