PHPackages                             zaidysf/idn-area-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. zaidysf/idn-area-laravel

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

zaidysf/idn-area-laravel
========================

Clean Indonesian Area Data Package for Laravel - Provinces, Regencies, Districts, Villages with curated official data

04↓93.3%[2 issues](https://github.com/zaidysf/idn-area-laravel/issues)PHPCI failing

Since Sep 10Pushed 5mo agoCompare

[ Source](https://github.com/zaidysf/idn-area-laravel)[ Packagist](https://packagist.org/packages/zaidysf/idn-area-laravel)[ RSS](/packages/zaidysf-idn-area-laravel/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

Indonesian Area Data for Laravel
================================

[](#indonesian-area-data-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/991ef0172d78ba5414ff97535fc38043b60490c0780b32bde652251c4eed5279/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a6169647973662f69646e2d617265612d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zaidysf/idn-area-laravel)[![GitHub Tests Action Status](https://camo.githubusercontent.com/607e22b9b21c1b0f8375ea6a7071cd7ec44ea0ecc5aeef23080a8b8ab82b0005/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a6169647973662f69646e2d617265612d6c61726176656c2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/zaidysf/idn-area-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/04c91de823ca407d92b020a9c34cdd488c4fffdaeef92a417e18876da58b481a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a6169647973662f69646e2d617265612d6c61726176656c2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/zaidysf/idn-area-laravel/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/28061a153df2e90f59ea6c590c3ea3f6ce20257373b3ce0c09a6f3b281b0e43a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a6169647973662f69646e2d617265612d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zaidysf/idn-area-laravel)

Clean and fast Indonesian administrative area data package for Laravel. Get provinces, regencies, districts, and villages with curated official data.

✨ Features
----------

[](#-features)

- 🌐 **API Mode (Recommended)** - Always up-to-date data via DataToko service
- 🚀 **Fast Local Mode** - No API calls, works offline
- 🧹 **Clean Data** - Curated and validated from official sources
- 🔍 **Search &amp; Filter** - Advanced search capabilities
- 📦 **Easy Setup** - Simple artisan commands
- ✅ **Laravel 10/11/12** - Full compatibility
- 🧪 **100% Tested** - 186 passing tests

📊 Data Coverage
---------------

[](#-data-coverage)

TypeCountSourceProvinces38Official Indonesian GovernmentRegencies514+Curated from BPS DataDistricts7,292+Updated RegularlyVillages84,345+Complete Coverage🚀 Installation
--------------

[](#-installation)

```
composer require zaidysf/idn-area-laravel
```

⚡ Quick Setup
-------------

[](#-quick-setup)

### 🌐 API Mode (Recommended)

[](#-api-mode-recommended)

Get always up-to-date data directly from official sources via DataToko service:

```
# Setup with API mode for real-time data
php artisan idn-area:setup --mode=api
```

**Why API Mode?**

- ✅ **Always Current** - Real-time data from official government sources
- ✅ **No Maintenance** - We handle all data updates automatically
- ✅ **Accurate** - Direct from BPS (Indonesian Central Statistics Agency)
- ✅ **Reliable** - Enterprise-grade DataToko infrastructure

### 🚀 Local Mode (Offline)

[](#-local-mode-offline)

For applications that need offline capability:

```
# Setup with local mode (uses curated CSV files)
php artisan idn-area:setup --mode=local
```

💡 Usage
-------

[](#-usage)

### 🏛️ Provinces

[](#️-provinces)

```
use zaidysf\IdnArea\Facades\IdnArea;

// Get all provinces
$provinces = IdnArea::getProvinces();
// Returns: [['code' => '11', 'name' => 'ACEH'], ...]

// Find specific province
$province = IdnArea::findProvince('11');
// Returns: ['code' => '11', 'name' => 'ACEH']

// Search provinces by name
$results = IdnArea::searchProvinces('jawa');
// Returns: [['code' => '32', 'name' => 'JAWA BARAT'], ...]

// Check if province exists
$exists = IdnArea::hasProvince('11'); // true
```

### 🏢 Regencies

[](#-regencies)

```
// Get all regencies in a province
$regencies = IdnArea::getRegencies('11'); // Aceh regencies
// Returns: [['code' => '1101', 'province_code' => '11', 'name' => 'SIMEULUE'], ...]

// Find specific regency
$regency = IdnArea::findRegency('1101');
// Returns: ['code' => '1101', 'province_code' => '11', 'name' => 'SIMEULUE']

// Search regencies in specific province
$results = IdnArea::searchRegencies('bandung', '32');
// Returns regencies containing 'bandung' in West Java

// Search regencies across all provinces
$allResults = IdnArea::searchRegencies('bandung');

// Check if regency exists
$exists = IdnArea::hasRegency('1101'); // true
```

### 🏘️ Districts

[](#️-districts)

```
// Get all districts in a regency
$districts = IdnArea::getDistricts('1101'); // Simeulue districts
// Returns: [['code' => '110101', 'regency_code' => '1101', 'name' => 'TEUPAH SELATAN'], ...]

// Find specific district
$district = IdnArea::findDistrict('110101');
// Returns: ['code' => '110101', 'regency_code' => '1101', 'name' => 'TEUPAH SELATAN']

// Search districts in specific regency
$results = IdnArea::searchDistricts('selatan', '1101');

// Search districts across all regencies
$allResults = IdnArea::searchDistricts('selatan');

// Check if district exists
$exists = IdnArea::hasDistrict('110101'); // true
```

### 🏡 Villages

[](#-villages)

```
// Get all villages in a district
$villages = IdnArea::getVillages('110101'); // Teupah Selatan villages
// Returns: [['code' => '1101012001', 'district_code' => '110101', 'name' => 'LATIUNG'], ...]

// Find specific village
$village = IdnArea::findVillage('1101012001');
// Returns: ['code' => '1101012001', 'district_code' => '110101', 'name' => 'LATIUNG']

// Search villages in specific district
$results = IdnArea::searchVillages('latiung', '110101');

// Search villages across all districts
$allResults = IdnArea::searchVillages('latiung');

// Check if village exists
$exists = IdnArea::hasVillage('1101012001'); // true
```

### 🔍 Advanced Search &amp; Utilities

[](#-advanced-search--utilities)

```
// Get complete hierarchy (province with all children)
$hierarchy = IdnArea::getHierarchy('11');
// Returns province with regencies, districts, and villages

// Get multiple areas by codes
$areas = IdnArea::getMultipleByCode(['11', '12', '13']);
// Returns array of provinces with specified codes

// Get statistics
$stats = IdnArea::getStatistics();
// Returns: ['provinces' => 38, 'regencies' => 514, 'districts' => 7292, 'villages' => 84345]

// Get all data (use with caution - large dataset)
$allData = IdnArea::getAllData();
```

### Using Models Directly

[](#using-models-directly)

```
use zaidysf\IdnArea\Models\Province;
use zaidysf\IdnArea\Models\Regency;

// Eloquent relationships
$province = Province::with('regencies')->find('11');
$regencyCount = $province->regencies->count();

// Search with scopes
$searchResults = Province::search('jawa')->get();
```

🔧 Configuration
---------------

[](#-configuration)

Publish the config file:

```
php artisan vendor:publish --tag="idn-area-config"
```

### 🌐 API Mode (Recommended for Production)

[](#-api-mode-recommended-for-production)

```
// config/idn-area.php
'mode' => 'api',
'datatoko_api' => [
    'base_url' => env('IDN_AREA_DATATOKO_URL', 'https://data.toko.center'),
    'access_key' => env('IDN_AREA_ACCESS_KEY'),
    'secret_key' => env('IDN_AREA_SECRET_KEY'),
],
```

Add to your `.env`:

```
IDN_AREA_MODE=api
IDN_AREA_ACCESS_KEY=your_access_key
IDN_AREA_SECRET_KEY=your_secret_key
```

**Get API Keys**: Contact [DataToko](https://data.toko.center) for enterprise-grade API access with guaranteed uptime and real-time data updates.

### 🚀 Local Mode (Development/Offline)

[](#-local-mode-developmentoffline)

```
// config/idn-area.php
'mode' => 'local', // Uses curated CSV files
```

🎛️ Artisan Commands
-------------------

[](#️-artisan-commands)

```
# Initial setup
php artisan idn-area:setup

# Switch between modes
php artisan idn-area:switch-mode api
php artisan idn-area:switch-mode local

# View package info
php artisan idn-area

# View statistics
php artisan idn-area:stats

# Cache management
php artisan idn-area:cache warm
php artisan idn-area:cache clear
```

🧪 Testing
---------

[](#-testing)

```
composer test
```

📈 Changelog
-----------

[](#-changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

🤝 Contributing
--------------

[](#-contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

🔒 Security Vulnerabilities
--------------------------

[](#-security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

📄 Credits
---------

[](#-credits)

- [zaidysf](https://github.com/zaidysf)
- [All Contributors](../../contributors)

📝 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

🇮🇩 About Indonesian Data
------------------------

[](#-about-indonesian-data)

This package provides official Indonesian administrative area data sourced from government databases. The data is curated and regularly updated to ensure accuracy and completeness.

**Data Sources:**

- Badan Pusat Statistik (BPS) - Indonesian Central Statistics Agency
- Official Government Administrative Records
- Validated and cleaned for consistency

**Use Cases:**

- E-commerce shipping forms
- Government applications
- Data analysis and reporting
- Location-based services
- Administrative systems

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance49

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity16

Early-stage or recently created project

 Bus Factor1

Top contributor holds 97.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5093672?v=4)[Zaid Yasyaf](/maintainers/zaidysf)[@zaidysf](https://github.com/zaidysf)

---

Top Contributors

[![zaidysf](https://avatars.githubusercontent.com/u/5093672?v=4)](https://github.com/zaidysf "zaidysf (39 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

### Embed Badge

![Health badge](/badges/zaidysf-idn-area-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/zaidysf-idn-area-laravel/health.svg)](https://phpackages.com/packages/zaidysf-idn-area-laravel)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
