Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wapnen/ghregionsdistrict
Laravel package for retreiving Ghana's regions and districts
https://github.com/wapnen/ghregionsdistrict
Last synced: 26 days ago
JSON representation
Laravel package for retreiving Ghana's regions and districts
- Host: GitHub
- URL: https://github.com/wapnen/ghregionsdistrict
- Owner: wapnen
- License: mit
- Created: 2018-03-03T00:11:45.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-03T18:20:44.000Z (almost 7 years ago)
- Last Synced: 2024-04-25T01:41:46.276Z (8 months ago)
- Language: PHP
- Size: 16.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## GhRegionsDistrict
Laravel package for retreiving Ghana's regions and districts## Installation
[PHP](https://php.net) 5.4+ and [Composer](https://getcomposer.org) are required.To get the latest version of this package add the following block of code to the require block of your project's composer.json
```
"wapnen/GHRegionsDistrict": "1.0.*"
```
You'll then need to run `composer install` or `composer update` to download it and have the autoloader updated.Once GhRegionsDistrict is installed, you need to register the service provider. Open up `config/app.php` and add the following to the `providers` key.
* `Wapnen\GhRegionDistrict\GhRegionDistrictServiceProvider::class,`
## Configuration
To start using this package, you'll need to publish all vendor assets:
```bash
$ php artisan vendor:publish --provider="Wapnen\GhRegionDistrict\GhRegionDistrictServiceProvider"
```Now migrate your database to include the regions and districts tables
```bash
$ php artisan migrate
```
Add the following to your application's Databaseseeder.php file```
$this->call(RegionTableSeeder::class);
$this->call(District1TableSeeder::class);
$this->call(District2TableSeeder::class);
$this->call(District3TableSeeder::class);
$this->call(District4TableSeeder::class);
$this->call(District5TableSeeder::class);
$this->call(District6TableSeeder::class);
$this->call(District7TableSeeder::class);
$this->call(District8TableSeeder::class);
$this->call(District9TableSeeder::class);
$this->call(District10TableSeeder::class);
```run the following command to Autoload your files
```
composer dump-autoload
```Finally run the following command to seed to your database
```bash
$ php artisan db:seed
```## Usage
To retrieve all the regions
```
$regions = DB::table('regions')->get();```
To retrieve one region
```
$region = DB::table('regions')->where('name', 'Ashanti)->first();
```To get all the districts for a particular region
```
$region = DB::table('regions')->where('name', 'Ashanti)->first();
$districts = DB::table('districts)->where('region_id' , $region->id)->get();
```
## ContributingPlease feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.
## Want to link up?
You can [follow me on twitter](https://twitter.com/_wapnen)!
## License
The MIT License (MIT).