Package Data | |
---|---|
Maintainer Username: | znck |
Maintainer Contact: | hi@znck.me (Rahul Kadyan) |
Package Create Date: | 2016-03-15 |
Package Last Update: | 2016-12-12 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:01:29 |
Package Statistics | |
---|---|
Total Downloads: | 1,184 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 4 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
A cities list provider for Laravel.
Either PHP 7.0+ is required.
To get the latest version of cities, simply require the project using Composer:
$ composer require znck/cities
Instead, you may of course manually update your require block and run composer update
if you so choose:
{
"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 return [
// ...
'providers' => [
// ....
Znck\Cities\CitiesServiceProvider::class,
]
// ...
];
City
trait in you Eloquent model.<?php namespace App;
use Illuminate\Database\Eloquent\Model;
use Znck\Cities\City as CityTrait;
class City extends Model {
use CityTrait;
}
php artisan cities:update
) to update list in database.Table names for cities and states are required. By default cities
and states
are used, but you can override these.
To get started, you'll need to publish all vendor assets:
php artisan vendor:publish --provider='Znck\Cities\CitiesServiceProvider'
This will create a config/cities.php
file in your app that you can modify to set your configuration. Also, make sure you check for changes to the original config file in this package between releases.
Expected schema:
Schema::create('countries', function (Blueprint $table) {
$table->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');
});
znck/state
and znck/countries
.Cities is licensed under The MIT License (MIT).