Git Product home page Git Product logo

cities's Introduction

Cities

A cities list provider for Laravel.

Cities

StyleCI Status Build Status Coverage Status Software License Packagist Latest Version Issues

Installation

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,
  ]
  // ...
];

Usage

<?php namespace App;

use Illuminate\Database\Eloquent\Model;
use Znck\Cities\City as CityTrait;

class City extends Model {
  use CityTrait;
}
  • Cities provides command (php artisan cities:update) to update list in database.

Configuration

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.

Conventions

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');
});

Development plan

  • 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).

cities's People

Contributors

suwardhan avatar znck avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

suwardhan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.