An open API service indexing awesome lists of open source software.

https://github.com/znck/cities

A list of cities.
https://github.com/znck/cities

cities laravel

Last synced: 6 months ago
JSON representation

A list of cities.

Awesome Lists containing this project

README

          

Cities
======
A cities list provider for [Laravel](https://laravel.com/).

![Cities](cover.png)



StyleCI Status


Build Status


Coverage Status


Software License


Packagist


Latest Version


Issues

## Installation

Either [PHP](https://php.net) 7.0+ is required.

To get the latest version of cities, simply require the project using [Composer](https://getcomposer.org):

```bash
$ composer require znck/cities
```

Instead, you may of course manually update your require block and run `composer update` if you so choose:

```json
{
"require": {
"znck/cities": "^0.1.2"
}
}
```

Once `Cities` is installed, you have to register its service provider. Open `config/app.php` and add `Znck\Cities\CitiesServiceProvider::class` to `providers` key. Your `config/app.php` should look like this.

```php
[
// ....
Znck\Cities\CitiesServiceProvider::class,
]
// ...
];
```

## Usage
- Use `City` trait in you [Eloquent](https://laravel.com/docs/master/eloquent) model.

```php
increments('id');
$table->string('name');
$table->string('code', 2)->unique();
$table->timestamps();
});

Schema::create('states', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('code', 5)->unique();
$table->unsignedInteger('country_id');
$table->timestamps();

$table->foreign('country_id')->references('id')->on('countries');
});

Schema::create('cities', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('code', 10)->unique();
$table->unsignedInteger('state_id');
$table->timestamps();

$table->foreign('state_id')->references('id')->on('states');
});

```

## Development plan
* [x] Create minimal working package.
* [ ] Add migrations.
* [ ] Integrate `znck/state` and `znck/countries`.
* [ ] Add major cities of India.
* [ ] Add translations in all 23 languages.
* [ ] Add major cities of World.

## License
Cities is licensed under [The MIT License (MIT)](LICENSE).