Faysal Ahamed

Full-stack Web Developer

Division, District and Upazila data of Bangladesh for Laravel application

by Faysal Ahamed

I was developing a Laravel app that required the Division, District and Upazila data. Before this, several times I manually created database table and imported sql data from https://github.com/nuhil/bangladesh-geocode

So no more manual works again. I created a package for Laravel application so that I can just user few command to get all desired data. Install using composer

1composer require devfaysal/laravel-bangladesh-geocode

Then publish the migrations and seeders

1php artisan vendor:publish --provider="Devfaysal\BangladeshGeocode\BangladeshGeocodeServiceProvider"

Then run the migration

1php artisan migrate

Run seeder

1php artisan db:seed --class=DivisionSeeder
2php artisan db:seed --class=DistrictSeeder
3php artisan db:seed --class=UpazilaSeeder

Github repo: https://github.com/devfaysal/laravel-bangladesh-geocode

Usage Literally any Laravel model functions can be used

1use Devfaysal\BangladeshGeocode\Models\Division;
2use Devfaysal\BangladeshGeocode\Models\District;
3use Devfaysal\BangladeshGeocode\Models\Upazila;
4 
5$divisions = Division::all();
6$districts = District::all();
7$upazilas = Upazila::all();
8 
9$division = Division::find(1);
10$districts = $division->districts;
11 
12$district = District::find(1);
13$upazilas = $district->upazilas;
14 
15//Use any Laravel model functions...