PHPackages                             schoolees/laravel-psgc - 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. [Database &amp; ORM](/categories/database)
4. /
5. schoolees/laravel-psgc

ActiveLibrary[Database &amp; ORM](/categories/database)

schoolees/laravel-psgc
======================

PSGC for Laravel: migrations, seeders, JSON data, models, services, resources, controllers, and read-only routes.

v1.0.0(2mo ago)21.4kMITPHPPHP ^8.1CI passing

Since Feb 17Pushed 2mo agoCompare

[ Source](https://github.com/Schoolees/schoolees-psgc.package)[ Packagist](https://packagist.org/packages/schoolees/laravel-psgc)[ RSS](/packages/schoolees-laravel-psgc/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

📍PSGC Laravel Package
=====================

[](#psgc-laravel-package)

[![Latest Stable Version](https://camo.githubusercontent.com/298a01aa529d259b01474e8cbc2fd854bac9824489617ef2761227b8224567a8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7363686f6f6c6565732f6c61726176656c2d707367632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/schoolees/laravel-psgc)[![Total Downloads](https://camo.githubusercontent.com/6a912a79f870b5e66fbf42cca8df64372c3c73d6bccc02e41f6a2bf1fe6fe9a8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7363686f6f6c6565732f6c61726176656c2d707367632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/schoolees/laravel-psgc)[![License](https://camo.githubusercontent.com/cb3eb5705b9aae60b63b31f0dd84b745fc3ef2ece2f6666e3c8ebc37226f61ed/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7363686f6f6c6565732f6c61726176656c2d707367632e7376673f7374796c653d666c61742d737175617265)](LICENSE)

A Laravel package for handling **Philippine Standard Geographic Code (PSGC)** data — including Regions, Provinces, Cities/Municipalities, and Barangays.

It comes complete with **migrations**, **seeders**, **JSON data**, **Eloquent models**, **services**, **controllers**, **API resources**, and **routes** following clean Laravel architecture.

---

📦 Features
----------

[](#-features)

- Full PSGC database structure (Regions, Provinces, Cities, Barangays)
- JSON PSGC dataset in `resources/psgc/`
- Database migrations and seeders for an initial data load
- Eloquent models with relationships and searchable fields
- Service layer for clean business logic
- REST API controllers &amp; resources
- Artisan command to regenerate PSGC models
- Ready-to-use API routes for all PSGC endpoints

📋 Requirements
--------------

[](#-requirements)

- PHP &gt;= 8.1
- Laravel &gt;= 10.x (tested on Laravel 12)
- MySQL / MariaDB

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

[](#-contributing)

Repository development/testing notes are in `CONTRIBUTING.md`.

⚙️ Installation
---------------

[](#️-installation)

**Require the package via Composer:**

```
composer require schoolees/laravel-psgc
```

**Quick installation:**

```
php artisan psgc:install --seed
```

**Publishing assets (optional):**

```
# Config
php artisan vendor:publish --tag=psgc-config

# Seeders
php artisan vendor:publish --tag=psgc-seeders

# Routes
php artisan psgc:publish-routes
php artisan psgc:publish-routes --force # Overwrite if re-running

# Resources
php artisan vendor:publish --tag=psgc-resources
```

**Generate PSGC models (optional):**

```
php artisan make:psgc-models
php artisan make:psgc-models --force # Overwrite existing models
php artisan make:psgc-models --softdeletes # Include SoftDeletes trait
```

**Example Request:**

```
# Get all Regions
GET /psgc/regions

# Get Provinces in Region 13
GET /psgc/provinces?region_code=130000000

# Get Cities in Province 133900000
GET /psgc/cities?province_code=133900000

# Get Barangays in City 133900000
GET /psgc/barangays?city_code=133900000
```

**Example JSON Response:**

```
{
  "code": 200,
  "draw": 1,
  "recordsFiltered": 17,
  "recordsTotal": 17,
  "recordsPerPage": 10,
  "data": [
    {
      "code": "133900000",
      "name": "City of Manila",
      "province_code": "133900000",
      "region_code": "130000000"
    }
  ],
  "filters": {
    "province_code": "133900000"
  }
}
```

**Filtering and Searching**

You can filter results by passing query parameters. Refer to the `getSearchable()` method on each model for available filterable fields.

**Example: Get Provinces in Region 13**

```
GET /psgc/provinces?region_code=130000000
```

**Example: Search for a city by name**

```
GET /psgc/cities?name=Manila
```

🔍 Searchable Fields
-------------------

[](#-searchable-fields)

Each model has a `getSearchable()` method to define searchable columns for filtering via API.

**Example for a City model:**

```
public function getSearchable(): array
{
    return [
        'query' => ['code', 'region_code', 'province_code'],
        'query_like' => ['name'],
    ];
}
```

🧩 Service Layer
---------------

[](#-service-layer)

The package follows the Service-Controller-Resource pattern for clean, maintainable code.

**Example:**

```
$results = $this->cityService->getCities(
    request()->all(),
    request()->input('order_by', 'id'),
    request()->input('sort_by', 'desc'),
    request()->input('limit', 10),
    request()->input('offset', 0)
);
```

Optional .env overrides
-----------------------

[](#optional-env-overrides)

**To customize API prefix:**

```
PSGC_API_PREFIX=geo # Will change /psgc/regions to /geo/regions.
```

**Route strategy (important):**

- Default: package auto-registers routes via service provider.
- If you want to use published `routes/psgc.php`, disable package route registration to avoid duplicates:

```
// config/psgc.php
'register_package_routes' => false,
```

**Pagination safety override:**

```
// config/psgc.php
'max_limit' => 100, // caps ?limit=...
```

📜 License
---------

[](#-license)

This package is open-sourced software licensed under the MIT license.

🏢 About
-------

[](#-about)

Developed &amp; maintained by Schoolees as part of the Schoolees Educational Suite.

📊 Data Source
-------------

[](#-data-source)

This package uses the official **Philippine Standard Geographic Code (PSGC)** dataset published by the **Philippine Statistics Authority (PSA)**.

Latest Dataset Used: [📄 PSGC 2Q 2025 Publication Datafile (Excel)](https://psa.gov.ph/system/files/scd/PSGC-2Q-2025-Publication-Datafile.xlsx)

Attribution: Philippine Statistics Authority — *Philippine Standard Geographic Code (PSGC)*

Update Frequency: Quarterly (based on PSA publication schedule)

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance84

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

84d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f80efb980bf06a05fb30e05c8cd52e4bef6372144667b93b38e3feb646d70719?d=identicon)[rpbaguio](/maintainers/rpbaguio)

---

Top Contributors

[![rpbaguio](https://avatars.githubusercontent.com/u/2038712?v=4)](https://github.com/rpbaguio "rpbaguio (64 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/schoolees-laravel-psgc/health.svg)

```
[![Health](https://phpackages.com/badges/schoolees-laravel-psgc/health.svg)](https://phpackages.com/packages/schoolees-laravel-psgc)
```

###  Alternatives

[jerome/filterable

Streamline dynamic Eloquent query filtering with seamless API request integration and advanced caching strategies.

19226.1k](/packages/jerome-filterable)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[ntanduy/cloudflare-d1-database

Easy configuration and setup for D1 Database connections in Laravel.

215.4k](/packages/ntanduy-cloudflare-d1-database)[dragon-code/laravel-http-logger

Logging incoming HTTP requests

319.8k3](/packages/dragon-code-laravel-http-logger)[bjuppa/laravel-blog

Add blog functionality to your Laravel project

483.3k2](/packages/bjuppa-laravel-blog)

PHPackages © 2026

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