subbe/gazetteer

This package is abandoned and no longer maintained. No replacement package was suggested.

A package build on Laravel 5 which provides a list of all the the Countries with their states and suburbs

v1.0.0 2016-01-09 13:35 UTC

This package is not auto-updated.

Last update: 2018-12-22 15:09:28 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

A package build on Laravel 5 which provides a list of all the the Countries with their states and suburbs

Countries available right now:-

  • Australia
  • Maldives

Install

1- composer require subbe/gazetteer

Open the file config\app.php

Add the following line to the providers array

Subbe\Gazetteer\GazetteerServiceProvider::class,

and this to the aliases array

'Gazetteer' => Subbe\Gazetteer\Facades\GazetteerFacade::class,

2- php artisan vendor:publish

Running this command will publish the migration and seed files to your application's 'migrations' and 'seeds' folder.

Update your DatabaseSeeder.php file found in your database/seeds folder and add the following to it.

  • $this->call(CountryTableSeeder::class);

  • $this->call(StateTableSeeder::class);

  • $this->call(SuburbTableSeeder::class);

  • $this->call(MaldiveIslandsTableSeeder::class);

Now run

3- composer dump-autload

4- php artisan migrate

This will add the 'countries', 'states', and 'suburbs' table to your database.

5- php artisan db:seed

Populate the tables created.

Usage

  • Gazetteer::countries() -> returns a collection of available countries
  • Gazetteer::countries($country_code) -> returns an instance of the requested country (searched by country code)
  • Gazetteer::countries($country_name) -> returns an instance of the requested country (searched by country name)
  • Gazetteer::states($country_code) -> returns a collection of states for a given country (searched by country code)
  • Gazetteer::states($country_name) -> returns a collection of states for a given country (searched by country name)
  • Gazetteer::suburbs($country, $states) -> returns a collection of states for a given country (searched by country name)
  • Gazetteer::suburb($input) -> returns an instance of a suburb for a given postcode (searched by postcode)
  • Gazetteer::suburb($input) -> returns an instance of a suburb for a given suburb name (searched by suburb name)