Code Monkey home page Code Monkey logo

laravel-countries-cities's Introduction

World Countries & Cities

A Laravel package for using world's popular countries and cities.

Features

  • Add the countries/cities to the database using migration and seeders.
  • Use the countries/cities directly from the package without using the database.

Installation

Require the package with composer:

composer require alakkad/world-countries-cities

Add the ServiceProvider to the providers array in config/app.php

'Alakkad\WorldCountriesCities\WorldCountriesCitiesServiceProvider',

Copy the package config and migrations files to your local directories with:

php artisan vendor:publish

Usage

Migration

After running php artisan vendor:publish you can directly run:

php artisan migrate

Seeders

In order to seed the migrated tables, you need to edit database/seeds/DatabaseSeeder.php and add the following lines:

public function run()
{
    Model::unguard();

    $this->call('Alakkad\WorldCountriesCities\CitiesSeeder');
    $this->call('Alakkad\WorldCountriesCities\CountriesSeeder');
}

Then run:

php artisan db:seed

Be careful, the seeders files truncate the tables before inserting, to prevent any duplication.

Direct usage

To be implementated.


Credits

The data is based on MySQL's world database example.

laravel-countries-cities's People

Contributors

ammarcodes avatar buro-buro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

laravel-countries-cities's Issues

Migrate error

i try to migrating city and country, but i got this error

[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key (SQL: create
table cities (id int unsigned not null auto_increment primary key, name varchar(35) not null, country_code varchar(3) not null, district varchar(20) not
null, population int unsigned not null auto_increment primary key) default character set utf8 collate utf8_unicode_ci engine = InnoDB)

can you help me how to fix it?

getting error on php artisan migrate

[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it
must be defined as a key (SQL: create table cities (id int unsigned not null auto_increment primary key, name varchar
(35) not null, country_code varchar(3) not null, district varchar(20) not null, population int unsigned not null auto_
increment primary key) default character set utf8 collate utf8_unicode_ci engine = InnoDB)

[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it
must be defined as a key

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.