luiscamp / laravel-peru-ubigeo
Peruvian ubigeo utilities for Laravel applications.
v0.1.2
2026-03-12 20:20 UTC
Requires
- php: ^8.2
- illuminate/database: ^10.0|^11.0|^12.0
- illuminate/routing: ^10.0|^11.0|^12.0
- illuminate/support: ^10.0|^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0|^10.0
- phpunit/phpunit: ^10.5|^11.0
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 --modelphp artisan ubigeo:publish --migrationphp 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(example010000). - Province code: ends with
00and excludes departments (example010100). - District responses return
id(notcode).
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