elbrahms / niger-location
This package offers a simple way to get the regions, departments, communes and localities of the Niger Republic (NE:+227) that you might need for your application - for example, for drop-down menus.
Requires
- illuminate/support: ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0
Requires (Dev)
- illuminate/contracts: ^5.8.15|^6.0
- illuminate/database: ^5.8.15|^6.0
- illuminate/filesystem: ^5.8.15|^6.0
- illuminate/support: ^5.8.15|^6.0
- mockery/mockery: ^1.0
- phpunit/php-code-coverage: ^7.0@dev
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2025-04-29 01:29:49 UTC
README
Introduction ๐
This package offers a simple way to get the regions, departments, communes and localities of the Niger Republic (NE:+227) that you might need for your application - for example, for drop-down menus.
Step One - Install via Composer ๐ผ
Require the package via composer into your project
composer require elbrahms/niger-location
Step Two - Publish Configurations โ๏ธ
Laravel location provides you with an easy way of customizing the tables used for storing Countries, States and Cities. Also, you can customisethe route prefix and middleware. To customize these you need to publish the configuration file. To publish the configuration file, run:
php artisan vendor:publish --tag=niger-location
You will have config/location.php
available for you to edit. The default configurations are:
<?php return [ 'countries_table' => 'countries', 'regions_table' => 'regions', 'departements_table' => 'departements', 'communes_table' => 'communes', 'localites_table' => 'localites', 'country_initial_id' => 159, //for Niger Republic 'routes' => [ 'prefix' => 'location', 'middleware' => 'web' ] ];
You can go ahead and customize the table names
, route prefix
and middleware
as you need before running the Migration.
Step Three - Running 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=Elbrahms\NigerLocation\Database\Seeders\LocationDatabaseSeeder
Usage ๐งจ
NOTE
The routes below are prefixed withlocation
which is the default configuration set in theconfig/location.php
file. If mofified, replace the prefixin your route with the correct prefix.
Here's the table in English:
Route | Description |
---|---|
/location/countries |
Returns all countries. |
/location/country/{id} |
Returns a single country by its ID. |
/location/regions |
Returns all regions. |
/location/region/{id} |
Returns a single region by its ID. |
/location/regions-by-country/{countryId} |
Returns all regions in a country using the country ID. |
/location/departements |
Returns all departments. |
/location/departement/{id} |
Returns a single department by its ID. |
/location/departements-by-region/{regionId} |
Returns all departments in a region using the region ID. |
/location/departements-by-country/{countryId} |
Returns all departments in a country using the country ID. |
/location/communes |
Returns all communes. |
/location/commune/{id} |
Returns a single commune by its ID. |
/location/communes-by-departement/{departementId} |
Returns all communes in a department using the department ID. |
/location/communes-by-region/{regionId} |
Returns all communes in a region using the region ID. |
/location/communes-by-country/{countryId} |
Returns all communes in a country using the country ID. |
/location/localites |
Returns all localities. |
/location/localite/{id} |
Returns a single locality by its ID. |
/location/localites-by-commune/{communeId} |
Returns all localities in a commune using the commune ID. |
/location/localites-by-departement/{departementId} |
Returns all localities in a department using the department ID. |
/location/localites-by-region/{regionId} |
Returns all localities in a region using the region ID. |
/location/localites-by-country/{countryId} |
Returns all localities in a country using the country ID. |
This table lists the routes defined in your code and provides a brief description of what each one returns.
Test
composer test
Contribution
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.