PHP code example of bodunde / states-and-local-govt
1. Go to this page and download the library: Download bodunde/states-and-local-govt library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bodunde / states-and-local-govt example snippets
...
use App\State;
use App\LocalGovt;
...
...
// fetch all states
$states = State::all();
// fetch state by id
$state = State::find($id) // where $id = 1
// fetch state by name
$state = State::findByName("Lagos State");
//get state local governments
$lg = $state->localGovernments;
// get all local governments
$lgs = LocalGovt::all();
// fetch local government by id
$lg = LocalGovt::find($id) // where $id = 1
// fetch local government state
$state = $lg->state;