PHP code example of lemonpatwari / bangladeshgeocode
1. Go to this page and download the library: Download lemonpatwari/bangladeshgeocode 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/ */
use lemonpatwari\bangladeshgeocode\Models\Division;
use lemonpatwari\bangladeshgeocode\Models\District;
use lemonpatwari\bangladeshgeocode\Models\Thana;
use lemonpatwari\bangladeshgeocode\Models\Union;
$divisions = Division::all();
$districts = District::all();
$thanas = Thana::all();
$unions = Union::all();
// Eager loading relations
$divisions = Division::with('districts')->get(); // Division hasMany District
$districts = District::with('division','thanas')->get(); // District belongsTo Division and hasMany Thana
$thanas = Thana::with('district','unions')->get(); // Thana belongsTo District and hasMany Union
$district = District::find(1);
$thanas = $district->thanas;
// Use any standard Eloquent methods