Districts
Introduction
By default, english language will be used. In order to use Nepali language, you have to specify while initiating the district object.
<?php
use Sagautam5\LocalStateNepal\Entities\District;
// English language will be selected by default
$district = new District();
You can specify language like this:
<?php
use Sagautam5\LocalStateNepal\Entities\District;
$district = new District('np');
Retrieving Districts
Once you initiate district entity, you can retrieve variety of data.
- Get list of all districts
<?php use Sagautam5\LocalStateNepal\Entities\District; $district = new District(); $districtList = $district->allDistricts();
-
Find district details by unique identifier
<?php use Sagautam5\LocalStateNepal\Entities\District; $district = new District(); $districtDetails = $district->find(1);
-
Get district with largest area
<?php use Sagautam5\LocalStateNepal\Entities\District; $district = new District(); $districtDetails = $district->largest();
-
Get district with smallest area
<?php use Sagautam5\LocalStateNepal\Entities\District; $district = new District(); $districtDetails = $district->smallest();
-
Get all districts and their municipalities
<?php use Sagautam5\LocalStateNepal\Entities\District; $district = new District(); $districtDetails = $district->getDistrictsWithMunicipalities();
-
Get all districts by province
<?php use Sagautam5\LocalStateNepal\Entities\District; $district = new District(); $districtDetails = $district->getDistrictsByProvince(3);
-
Search districts by key and value with exact match option
<?php use Sagautam5\LocalStateNepal\Entities\District; $district = new District(); $districtDetails = $district->search('name','Gulmi'); // For exact match, pass optional parameter $exact as true $districtDetails = $district->search('name','Gulmi', true);
List of options for parameter key:
['id', 'province_id', 'name', 'area_sq_km', 'website', 'headquarter'];
-
Recursive search with multiple set of key value data
<?php use Sagautam5\LocalStateNepal\Entities\District; $district = new District(); $params = [ ['key' => 'headquarter', 'value' => 'some name', 'exact' => true], ['key' => 'id', 'value' => 'some id', 'exact' => true] ]; $districtDetails = $district->recursiveSearch($params); // if you have already filtered district data in structured format, then you can pass the data in recursive search $data = $district->search('name', 'some name', false); $districtDetails = $district->search($params, $data);
List of options for parameter key:
['id', 'province_id', 'name', 'area_sq_km', 'website', 'headquarter'];