harrym/indonesian-regions
最新稳定版本:2.0.0
Composer 安装命令:
composer require harrym/indonesian-regions
包简介
Indonesian Region Database for Laravel
README 文档
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.
统计信息
- 总下载量: 62
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-21