PHP code example of devfaysal / laravel-bangladesh-geocode

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

    

devfaysal / laravel-bangladesh-geocode example snippets


use Devfaysal\BangladeshGeocode\Models\District;
use Devfaysal\BangladeshGeocode\Models\Division;
use Devfaysal\BangladeshGeocode\Models\Union;
use Devfaysal\BangladeshGeocode\Models\Upazila;

$divisions = Division::orderBy('name')->get(['id', 'name', 'bn_name']);

$division = Division::with('districts')->where('name', 'Dhaka')->firstOrFail();
$districts = $division->districts;

$district = District::with('upazilas')->findOrFail(1);
$upazilas = $district->upazilas;

$upazila = Upazila::with('unions')->findOrFail(261); // Charfesson
$unions = $upazila->unions;

$union = Union::with('upazila')->findOrFail(2352); // Awajpur
$parentUpazila = $union->upazila;

use Devfaysal\BangladeshGeocode\Models\District;
use Devfaysal\BangladeshGeocode\Models\PostOffice;

$district = District::with('postOffices')->findOrFail(47);
$postOffices = $district->postOffices;

$matches = PostOffice::where('post_code', '1360')->get();

use Devfaysal\BangladeshGeocode\Models\Division;

$division = Division::findOrFail($divisionId);
$districtOptions = $division->districts()
    ->orderBy('name')
    ->get(['id', 'name', 'bn_name']);
bash
php artisan BangladeshGeocode:addnew --force --no-interaction
bash
php artisan BangladeshGeocode:addpourashava
bash
php artisan db:seed --class="Devfaysal\BangladeshGeocode\Seeders\PostOfficeSeeder"
bash
php artisan BangladeshGeocode:setup
bash
php artisan boost:install
bash
php artisan BangladeshGeocode:addnew