Download the PHP package gerardojbaez/geodata without Composer
On this page you can find all versions of the php package gerardojbaez/geodata. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gerardojbaez/geodata
More information about gerardojbaez/geodata
Files in gerardojbaez/geodata
Package geodata
Short Description Laravel 5.2 package that provides basic geographical data like Countries, Regions and Cities.
License MIT
Informations about the package geodata
GeoData
GeoData is a Laravel package that provides basic geographical data like Countries, Regions and Cities.
Content
- Installation
- Composer
- Service Provider
- Migrations and Seeders
- Traits and Contracts
- Available Countries
- Usage
- Installing Countries
- Models
- Controllers
- Routes
- License
Installation
Composer
Pull this package through Composer (file composer.json
)
Run this command inside your terminal.
composer update
Service Provider
Add the package to your application service providers in config/app.php file.
Migrations and Seeders
Publish package migrations and seeders with:
php artisan vendor:publish
Then run migrations.
php artisan migrate
If you want all countries, run:
php artisan db:seed --class AllCountriesSeeder
If you want specific countries, run:
php artisan db:seed --class Gerardojbaez\\GeoData\\Seeders\\UnitedStatesSeeder
php artisan db:seed --class Gerardojbaez\\GeoData\\Seeders\\PuertoRicoSeeder
[...]
Check available countries below.
Available Countries
Countries |
---|
Afghanistan |
Albania |
Algeria |
Andorra |
Angola |
Antigua and Barbuda |
Argentina |
Aruba |
Australia |
Austria |
Bahamas |
Barbados |
Belgium |
Belize |
Bermuda |
Bolivia |
Brazil |
Canada |
Chile |
China |
Colombia |
Costa Rica |
Croatia |
Cuba |
Czech Republic |
Denmark |
Dominican Republic |
Ecuador |
El Salvador |
Equatorial Guinea |
Estonia |
Finland |
France |
Germany |
Greece |
Greenland |
Guatemala |
Guyana |
Haiti |
Honduras |
Hong Kong |
India |
Indonesia |
Ireland |
Israel |
Italy |
Ivory Coast |
Jamaica |
Japan |
Latvia |
Lebanon |
Luxembourg |
Malaysia |
Mexico |
Morocco |
Netherlands |
Nicaragua |
Nigeria |
Norway |
Pakistan |
Panama |
Papua New Guinea |
Paraguay |
Peru |
Philippines |
Poland |
Portugal |
Puerto Rico |
Romania |
Russia |
Saint Lucia |
San Marino |
Singapore |
South Africa |
Spain |
Sri Lanka |
Sweden |
Switzerland |
Thailand |
Turkey |
United Kingdom |
United States |
Uruguay |
Venezuela |
Traits and Contracts
You can use GeoData traits when you need to define a relation to countries, regions and/or cities.
See the following example:
Usage
Installing Countries
In addition to install countries via command line using seeders, you can also
install countries through the CountryInstaller
class. This will help you create a "web interface" that will give your customers or users the ability to install countries as needed. The installer will check if the country has been already installed and in that case will throw Gerardojbaez\Geodata\Exceptions\CountryAlreadyInstalledException
.
The installation include:
- The country
- Country Regions
- Country Cities
It's as simple as:
Models
This package comes with Gerardojbaez\GeoData\Models\Country
,
Gerardojbaez\GeoData\Models\Region
and
Gerardojbaez\GeoData\Models\City
models.
Take a look at each model for more details.
Controllers
If you want to provide countries, regions and/or cities data to your frontend you may want to use
Gerardojbaez\GeoData\Controllers\CountriesController
,
Gerardojbaez\GeoData\Controllers\RegionsController
and
Gerardojbaez\GeoData\Controllers\CitiesController
controllers.
Controllers returns a json reponse containing (if any) the requested data.
Routes
This is an example. You can structure these routes as you want.
License
This package is free software distributed under the terms of the MIT license.