PHP Classes

ngstates: Retrieve information about Nigeria states

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 37 All time: 10,955 This week: 206Up
Version Licenses PHP version Categories
ngstates 0.1.0Custom (specified...5PHP 5, Files and Folders, Geography
Description 

Author

This package is specific mainly for applications used in Nigeria Nigeria .

This class can retrieve information about Nigeria states.

It can return information about a given state in Nigeria based on information stored in a file in the JSON format.

Currently it can get the list of all states, get information about a state using the state name or number, state local governments, etc..

Picture of Josiah Ovye Yahaya
  Performance   Level  
Name: Josiah Ovye Yahaya <contact>
Classes: 6 packages by
Country: Nigeria Nigeria
Age: 34
All time rank: 231613 in Nigeria Nigeria
Week rank: 170 Up6 in Nigeria Nigeria Up
Innovation award
Innovation award
Nominee: 1x

Documentation

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
  2. Add state
  3. Add state local governments
  4. Add state local government
  5. Get all states
  6. Get state
  7. Get state local governments
  8. Get state local government
  9. Update state
  10. Update state local governments
  11. Update state local government
  12. Delete state
  13. Delete state local government

Usage

// 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

// Get states
$ngStates->getStates();

// This will return an array of all states.

// Get State
$ngStates->getState(string|int $stateNameOrId);

// e.g
$ngStates->getState(26); 

// OR
$ngStates->getState('Nasarawa State');

// Get state local governments
$ngStates->getStateLocals(string|int $stateNameOrId);

// e.g
$ngStates->getStateLocals(26);

// OR
$ngStates->getStateLocals('Nasarawa State');

// 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

// 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'
        ]
    ]],
]);

// 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',
    ]
  ]
]);
// 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'
   ]
]);

// Add single local government
$ngStates->addStateLocal(string|int $stateNameOrId, array $localData);

// e.g
$ngStates->addStateLocal(38, [
    'id' => 5,
    'name' => 'Demo LGA Five'
]);

Update records

// 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'
        ]
    ]
]);

// 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'
    ]
]);

// Update state local
$ngStates->updateStateLocal(string|int $stateNameOrId, array $localData);

// e.g
$ngStates->updateStateLocal(38, [
    [
        'id' => 1,
        'name' => 'Demo LGA Changed'
    ]
]);

Delete records

// Delete state
$ngStates->deleteState(int $stateNameOrId);

// e.g
$ngStates->deleteState(38);

// Delete state local government
$ngStates->deleteStateLocal(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 project is licenced under MIT License. Read through the <a href="https://github.com/coderatio/ngstates/blob/master/LICENSE">license here</a>.


  Files folder image Files (6)  
File Role Description
Files folder imagesrc (3 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (6)  /  src  
File Role Description
  Accessible without login Plain text file helpers.php Data Auxiliary data
  Accessible without login Plain text file locations.json Data Auxiliary data
  Plain text file NGStates.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:37
This week:0
All time:10,955
This week:206Up