PHP code example of unicodeveloper / laravel-ngsc

1. Go to this page and download the library: Download unicodeveloper/laravel-ngsc 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/ */

    

unicodeveloper / laravel-ngsc example snippets


'aliases' => [
    ...
    'Ngsc' => Unicodeveloper\Ngsc\Facades\NgscFacade::class,
    ...
]


namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use Unicodeveloper\Ngsc\Ngsc;
use App\Http\Controllers\Controller;

class StateController extends Controller
{
    protected $ngsc;

    public function __construct(Ngsc $ngsc)
    {
        $this->ngsc = $ngsc;
    }

    /**
     * Get all states
     * @return array
     */
    public function getAllStates()
    {
        return $this->ngsc->getAllStates();
    }
}


/**
 * Gets all the states in Nigeria
 * @return array
 */
Ngsc::getAllStates()

/**
 * Gets the details of just one state, e.g capital, lat, lng
 * @param string  state or state code
 * @return array
 */
Ngsc::getOneState('lagos') OR Ngsc::getOneState('LA')

/**
 * Gets the local government areas of just one state
 * @param string  state or state code
 * @return array
 */
Ngsc::getLGAS('lagos') OR Ngsc::getLGAS('LA')

/**
 * Gets the cities of just one state
 * @param string  state or state code
 * @return array
 */
Ngsc::getCities('lagos') OR Ngsc::getCities('LA')
bash
$ php artisan vendor:publish --provider="Unicodeveloper\Ngsc\NgscServiceProvider"