This Package offers a simple way to get Countries, Cities and States that you may need for your Application, most especially for dropdown menus.
Require the package via composer into your project
composer require ichtrojan/laravel-location
Next, publish the Seeders from the package
php artisan vendor:publish --tag=laravel-location-seeds
or Run
php artisan vendor:publish
You will end up with a selection like this
input the number that matches with Ichtrojan\Location\LocationServiceProvider
and press enter.
Step Three
Run migrations
before you do this make sure your correct Database credentials are set in the
.env
file
php artisan migrate
Finally, run the Package seeders
php artisan db:seed --class=LocationDatabaseSeeder
Endpoint | Description |
---|---|
/location/countries |
return all countries |
/location/country/{id} |
return a single country by its ID |
/location/states |
return all states |
/location/state/{id} |
return a single state by its ID |
/location/states/{countryID} |
return all states in a country using the country ID |
/location/cities |
return all cities |
/location/city/{id} |
return a single city by its ID |
/location/cities/{stateID} |
return all cities in a state using the state ID |
Free for all, if you find an issue with the package or if a group of people somehow created a new country please send in a PR.
Danke Schön