Skip to the content.

Municipalities

Introduction

By default, english language will be used. In order to use Nepali language, you have to specify while initiating the municipality object.

<?php

use Sagautam5\LocalStateNepal\Entities\Municipality;

// English language will be selected by default
$municipality = new Municipality();

You can specify language like this:

<?php

use Sagautam5\LocalStateNepal\Entities\Municipality;

$municipality = new Municipality('np');

Retrieving Municipalities

Once you initiate municipality entity, you can retrieve variety of data.

  1. Get list of all municipalities
     <?php
        
     use Sagautam5\LocalStateNepal\Entities\Municipality;
        
     $municipality = new Municipality();
        
     $municipalityList = $municipality->allMunicipalities();
    
  2. Find municipality details by unique identifier

     <?php
        
     use Sagautam5\LocalStateNepal\Entities\Municipality;
        
     $municipality = new Municipality();
        
     $municipalityDetails = $municipality->find(1);
    
  3. Get municipality with largest area

     <?php
        
     use Sagautam5\LocalStateNepal\Entities\Municipality;
        
     $municipality = new Municipality();
        
     $municipalityDetails = $municipality->largest();
    
  4. Get municipality with smallest area

     <?php
        
     use Sagautam5\LocalStateNepal\Entities\Municipality;
        
     $municipality = new Municipality();
        
     $municipalityDetails = $municipality->smallest();
    
  5. Get all municipalities by district id

     <?php
        
     use Sagautam5\LocalStateNepal\Entities\Municipality;
        
     $municipality = new Municipality();
        
     $municipalityDetails = $municipality->getMunicipalitiesByDistrict(12);
    
  6. Get all municipalities by category id

     <?php
        
     use Sagautam5\LocalStateNepal\Entities\Municipality;
        
     $municipality = new Municipality();
        
     $municipalityDetails = $municipality->getMunicipalityByCategory(4);
    
  7. Get all wards of a municipality

    <?php
       
    use Sagautam5\LocalStateNepal\Entities\Municipality;
       
    $municipality = new Municipality();
       
    $municipalityDetails = $municipality->wards(4);
    
  8. Search municipalities by key and value with exact match option

    <?php
       
    use Sagautam5\LocalStateNepal\Entities\Municipality;
       
    $municipality = new Municipality();
      
    $municipalityDetails = $municipality->search('name','Kathmandu');
        
    // For exact match, pass optional parameter $exact as true 
    $municipalityDetails = $municipality->search('name','Kathmandu', true);
    

    List of options for parameter key:

        ['id', 'district_id', 'category_id', 'name', 'area_sq_km', 'website', 'wards']
    
  9. Recursive search with multiple set of key value data

     <?php
        
     use Sagautam5\LocalStateNepal\Entities\Municipality;
        
     $municipality = new Municipality();
     $params = [
                  ['key' => 'municipality_id', 'value' => 'some id', 'exact' => true],   
                  ['key' => 'wards', 'value' => 'some ward', 'exact' => true]
      ];
     $municipalityDetails = $municipality->recursiveSearch($params);   
        
     // if you have already filtered municipality data in structured format, then you can pass the data in recursive search
     $data =  $municipality->search('name', 'some name', false); 
        
     $municipalityDetails = $municipality->search($params, $data);
    

    List of options for parameter key:

     ['id', 'district_id', 'category_id', 'name', 'area_sq_km', 'website', 'wards'];