harrym / indonesian-regions
Indonesian Region Database for Laravel
2.0.0
2026-02-21 18:01 UTC
Requires
- php: ^8.2
- spatie/laravel-data: ^4.0.0
Requires (Dev)
- driftingly/rector-laravel: ^2.1
- larastan/larastan: ^3.9
- laravel/pint: ^1.0
- orchestra/testbench: ^9.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.0
- rector/rector: ^2.2
README
A fast, lightweight, and modern Indonesian Region Database (Provinsi, Kota/Kabupaten, Kecamatan, Kelurahan/Desa) package for Laravel.
Installation
You can install the package via composer:
composer require harrym/indonesian-regions
After installation, publish the database migrations and configuration:
php artisan vendor:publish --provider="HarryM\IndonesianRegions\IndonesianRegionsServiceProvider"
Then run the migrations to create the required tables:
php artisan migrate
Finally, seed the regions database (this process handles bulk upserts securely and efficiently):
php artisan db:seed --class="HarryM\IndonesianRegions\Database\Seeders\RegionSeeder"
Structure
The provided datasets contain data mapped into four levels of regions:
AreaProvince(Provinces)AreaCity(Cities & Regencies / Kota & Kabupaten)AreaDistrict(Districts / Kecamatan)AreaSubdistrict(Subdistricts & Villages / Kelurahan & Desa)
Usage
All Area models use Laravel's standard Eloquent system. You can interact with them statically or via relationships:
use HarryM\IndonesianRegions\Models\AreaProvince; use HarryM\IndonesianRegions\Models\AreaCity; // Get all provinces $provinces = AreaProvince::all(); // Get the cities of a specific province using relationship $province = AreaProvince::where('name', 'DKI JAKARTA')->first(); $jakartaCities = $province->cities; // Get the district associated with a city $city = AreaCity::where('name', 'KOTA JAKARTA SELATAN')->first(); $districts = $city->districts; // Get subdistricts of a specific district $district = $city->districts()->first(); $subdistricts = $district->subdistricts;
Testing
composer test
License
The MIT License (MIT). Please see License File for more information.