$ composer require dmitriymarley/laraglobe
To install package manually, just add the following line into your composer.json
file
"dmitriymarley/laraglobe": "1.0.*"
and run
composer update
After you installed the package via composer, you need to add the following line into your config/app.php
file:
DmitriyMarley\LaraGlobe\LaraGlobeServiceProvider::class,
Also, you may add an alias into aliases
array in order to use LaraGlobeFacade
:
'Globe' => DmitriyMarley\LaraGlobe\Facades\LaraGlobeFacade::class,
Next, to populate your database, you need to run:
php artisan globe:populate
The globe:drop
command will remove all tables and data:
php artisan globe:drop
To get all the countries from your database, you can use the following:
Globe::getCountries()
You can get countries with states by using getCountriesWithStates
method, like so:
Globe::getCountriesWithStates()
And also, you can get countries with states and cities:
Globe::getCountriesithStatesAndCities()
To perform a custom SQL query, there are 3 methods to get the Country
, City
and State
models themselves:
Globe::getCountryModel() // will return default Country model
Globe::getCityModel() // will return default City model
Globe::getStateModel() // will return default State model