luiscamp/laravel-peru-ubigeo

Peruvian ubigeo utilities for Laravel applications.

Maintainers

Package info

github.com/jorarmarfin/laravel-peru-ubigeo

pkg:composer/luiscamp/laravel-peru-ubigeo

Statistics

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.2 2026-03-12 20:20 UTC

This package is auto-updated.

Last update: 2026-05-12 20:45:57 UTC


README

Base package to work with Peruvian ubigeo data in Laravel.

Installation

composer require luiscamp/laravel-peru-ubigeo

Quick start after install

# 1) Publish migration
php artisan vendor:publish --tag=ubigeo-migrations

# 2) Run migrations
php artisan migrate

# 3) Publish seeder
php artisan vendor:publish --tag=ubigeo-seeders

# 4) Seed ubigeo data
php artisan db:seed --class="Database\\Seeders\\UbigeoSeeder"

Publish config

php artisan vendor:publish --tag=ubigeo-config

Publish migrations

php artisan vendor:publish --tag=ubigeo-migrations
php artisan migrate

Publish model + migration (single command)

php artisan ubigeo:publish

Options:

  • php artisan ubigeo:publish --model
  • php artisan ubigeo:publish --migration
  • php artisan ubigeo:publish --force

Publish and run seeder

php artisan vendor:publish --tag=ubigeo-seeders
php artisan db:seed --class="Database\\Seeders\\UbigeoSeeder"

API endpoints

By default the prefix is ubigeo and middleware is api.

GET /ubigeo/search?code=010000
GET /ubigeo/search?name=lima
GET /ubigeo/departments?name=ama
GET /ubigeo/provinces/010000?name=chacha
GET /ubigeo/districts/010100?name=asuncion

Rules:

  • Department code: ends with 0000 (example 010000).
  • Province code: ends with 00 and excludes departments (example 010100).
  • District responses return id (not code).

Trait methods

use LaravelPeru\Ubigeo\Traits\InteractsWithUbigeo;

class UbigeoService
{
    use InteractsWithUbigeo;
}

Available methods:

  • getDepartament(?string $name = null)
  • getProvice(string $code, ?string $name = null)
  • getDistrict(string $code, ?string $name = null)

Testing

composer test