-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
798 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Josiah Ovye Yahaya | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
MIT License | ||
Copyright (c) 2018 Josiah Ovye Yahaya | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,226 @@ | ||
# ngstates | ||
A stand-alone database of Nigeria states and local government manager written for php developers | ||
# NGstates | ||
A stand-alone database of Nigeria states and local government manager written for php developers. | ||
|
||
# Download | ||
`composer require coderatio/ngstates` or clone this repo to use it mannually. _We don't recommend manual download._ | ||
|
||
## What you can do with it. | ||
1. Add states | ||
1. Add state | ||
1. Add state local governments | ||
1. Add state local government | ||
1. Get all states | ||
1. Get state | ||
1. Get state local governments | ||
1. Get state local government | ||
1. Update state | ||
1. Update state local governments | ||
1. Update state local government | ||
1. Delete state | ||
1. Delete state local government | ||
|
||
## Usage | ||
```php | ||
// If you downloaded the library using composer | ||
require 'vendor/autoload.php'; | ||
|
||
// If you didn't download the library via composer. | ||
require 'src/NGStates.php'; | ||
|
||
$ngStates = new Coderatio\NGStates\NGStates(); | ||
/* | ||
* Note: You can use the helper function which is an instance of NGStates::class. | ||
* e.g ngstates()->getStates(); | ||
*/ | ||
|
||
print_r($ngStates->getStates()); // Print all the states | ||
exit; | ||
``` | ||
|
||
### Fetch records | ||
```php | ||
// Get states | ||
$ngStates->getStates(); | ||
|
||
// This will return an array of all states. | ||
``` | ||
|
||
```php | ||
// Get State | ||
$ngStates->getState(string|nt $stateNameOrId); | ||
|
||
// e.g | ||
$ngStates->getState(26); | ||
|
||
// OR | ||
$ngStates->getState('Nasarawa State'); | ||
``` | ||
|
||
```php | ||
// Get state local governments | ||
$ngStates->getStateLocals(string|int $stateNameOrId); | ||
|
||
// e.g | ||
$ngStates->getStateLocals(26); | ||
|
||
// OR | ||
$ngStates->getStateLocals('Nasarawa State'); | ||
``` | ||
|
||
```php | ||
// Get state local government | ||
$ngState->getStateLocal(string|int $stateNameOrId, string|int $localNameOrId); | ||
|
||
// e.g | ||
$ngStates->getStateLocal(26, 1); | ||
|
||
// OR | ||
$ngStates->getStateLocal('Nasarawa State', 'Lafia'); | ||
``` | ||
|
||
### Add new records | ||
```php | ||
// Add multiple states to database | ||
$ngStates->addStates(array $statesData); | ||
|
||
// e.g | ||
$ngStates->addStates([ | ||
['state' => [ | ||
'id' => 38, | ||
'name' => 'Demo State' | ||
'locals' => [ | ||
'id' => 1, | ||
'name' => 'Demo LGA One' | ||
] | ||
]], | ||
['state' => [ | ||
'id' => 39, | ||
'name' => 'Demo State Two' | ||
'locals' => [ | ||
'id' => 1, | ||
'name' => 'Demo LGA One' | ||
] | ||
]], | ||
]); | ||
|
||
``` | ||
|
||
```php | ||
// Add a state | ||
$ngStates->addState(array $stateData); | ||
|
||
// e.g | ||
$ngStates->addState([ | ||
'id' => 38, | ||
'name' => 'Demo State', | ||
'locals' => [ | ||
[ | ||
'id' => 1, | ||
'name' => 'Demo LGA One' | ||
], | ||
[ | ||
'id' => 2, | ||
'name' => 'Demo LGA Two', | ||
] | ||
] | ||
]); | ||
``` | ||
```php | ||
// Add state local governments | ||
$ngStates->addStateLocals(string|int $stateNameOrId, array $localsData); | ||
|
||
// e.g | ||
$ngStates->addStateLocals(38, [ | ||
[ | ||
'id' => 3, | ||
'name' => 'Demo LGA Three', | ||
], | ||
[ | ||
'id' => 4, | ||
'name' => 'Demo LGA Four' | ||
] | ||
]); | ||
``` | ||
|
||
```php | ||
// Add single local government | ||
$ngStates->addStateLocal(string|int $stateNameOrId, array $localData); | ||
|
||
// e.g | ||
$ngStates->addStateLocal(38, [ | ||
'id' => 5, | ||
'name' => 'Demo LGA Five' | ||
]); | ||
``` | ||
|
||
### Update records | ||
```php | ||
// Update state | ||
$ngStates->updateState(string|int $stateNameOrId, array $stateData); | ||
|
||
// e.g | ||
$ngStates->updateState(38, [ | ||
'name' => 'Demo State Edited', | ||
'locals' => [ | ||
[ | ||
'id' => 1, | ||
'name' => 'Demo LGA One Edited' | ||
] | ||
] | ||
]); | ||
``` | ||
|
||
```php | ||
// Update state local governments | ||
$ngStates->updateStateLocals(string|int $stateNameOrId, array $localsData); | ||
|
||
// e.g | ||
$ngStates->updateStateLocals(38, [ | ||
[ | ||
'id' => 1, | ||
'name' => 'Demo LGA One Updated' | ||
], | ||
[ | ||
'id' => 2, | ||
'name' => 'Demo LGA Two Updated' | ||
] | ||
]); | ||
|
||
``` | ||
|
||
```php | ||
// Update state local | ||
$ngStates->updateStateLocal(string|int stateNameOrId, array $localData); | ||
|
||
// e.g | ||
$ngStates->updateStateLocal(38, [ | ||
[ | ||
'id' => 1, | ||
'name' => 'Demo LGA Changed' | ||
] | ||
]); | ||
``` | ||
|
||
### Delete records | ||
```php | ||
// Delete state | ||
$ngStates->deleteState(int $stateNameOrId); | ||
|
||
// e.g | ||
$ngStates->deleteState(38); | ||
``` | ||
|
||
```php | ||
// Delete state local government | ||
$ngStates->deleteStateLocals(string|int $stateNameOrId, int $stateLocalId); | ||
|
||
// e.g | ||
$ngStates->deleteStateLocal(38, 1); // Will delete local government with the ID 1. | ||
``` | ||
|
||
## Contribution | ||
|
||
To contribute, kindly fork the repo and send a pull request or find me on <a href="https://twitter.com/josiahoyahaya">Twitter</a>. | ||
|
||
## Licence | ||
This porject is licenced under MIT License. Read through the <a href="https://github.com/coderatio/ngstates/blob/master/LICENSE">license here</a>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "coderatio/ngstatesdb", | ||
"description": "A stand-alone database of Nigeria states and local government manager written for php developers", | ||
"type": "library", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Josiah Ovye Yahaya", | ||
"email": "josiahoyahaya@gmail.com" | ||
} | ||
], | ||
"autoload": { | ||
"classmap": [ | ||
"src" | ||
], | ||
"files": [ | ||
"src/helpers.php" | ||
], | ||
"psr-4": { | ||
"Coderatio\\NGStates\\NGStates\\": "src/" | ||
} | ||
}, | ||
"minimum-stability": "dev", | ||
"require": { | ||
"php": ">=5.6" | ||
} | ||
} |
Oops, something went wrong.