baironbernal / colombia-locations
Paquete con todos los departamentos y municipios de Colombia para Laravel
Package info
github.com/baironbernal/colombia-locations
pkg:composer/baironbernal/colombia-locations
Requires
- php: ^8.1
- illuminate/database: ^10.0|^11.0|^12.0
- illuminate/support: ^10.0|^11.0|^12.0
This package is auto-updated.
Last update: 2026-05-11 19:22:10 UTC
README
A Laravel package that provides all 33 departments and 1,122+ municipalities of Colombia, based on official DANE (Departamento Administrativo Nacional de Estadística) codes.
Requirements
- PHP 8.1+
- Laravel 10, 11, or 12
Installation
Install the package via Composer:
composer require baironbernal/colombia-locations
Laravel will automatically discover the service provider. Then run the migrations:
php artisan migrate
Finally, seed the database with all Colombian departments and municipalities:
php artisan db:seed --class="BaironBernal\ColombiaLocations\Database\Seeders\ColombiaLocationsSeeder"
Database Structure
departments table
| Column | Type | Description |
|---|---|---|
id |
bigint (PK) | Auto-incremental primary key |
code |
varchar(2) | Official DANE code (e.g. "05") |
name |
varchar(100) | Department name (e.g. "Antioquia") |
municipalities table
| Column | Type | Description |
|---|---|---|
id |
bigint (PK) | Auto-incremental primary key |
code |
varchar(5) | Official DANE code (e.g. "05001") |
name |
varchar(150) | Municipality name (e.g. "Medellín") |
department_id |
bigint (FK) | Foreign key to departments.id |
About DANE codes: The municipality code is formed by the 2-digit department code + 3 digits for the municipality. For example,
05001= Medellín (05= Antioquia,001= Medellín).
Usage
The package ships with two Eloquent models you can use directly.
Get all departments
use BaironBernal\ColombiaLocations\Models\Department; $departments = Department::all();
Get all municipalities of a department
use BaironBernal\ColombiaLocations\Models\Department; $antioquia = Department::where('code', '05')->first(); $municipalities = $antioquia->municipalities;
Get a municipality with its department
use BaironBernal\ColombiaLocations\Models\Municipality; $medellin = Municipality::where('code', '05001')->first(); echo $medellin->name; // "Medellín" echo $medellin->department->name; // "Antioquia"
Search municipalities by name
use BaironBernal\ColombiaLocations\Models\Municipality; $results = Municipality::where('name', 'like', '%bogotá%')->get();
Get departments with their municipalities eager loaded
use BaironBernal\ColombiaLocations\Models\Department; $departments = Department::with('municipalities')->get();
Publishing Assets
If you want to customize the migrations or seeders, you can publish them to your project:
# Publish migrations php artisan vendor:publish --tag=colombia-locations-migrations # Publish seeders php artisan vendor:publish --tag=colombia-locations-seeders
Data Coverage
| Department | Municipalities |
|---|---|
| Antioquia | 125 |
| Atlántico | 23 |
| Bogotá D.C. | 1 |
| Bolívar | 46 |
| Boyacá | 123 |
| Caldas | 27 |
| Caquetá | 16 |
| Cauca | 42 |
| Cesar | 25 |
| Chocó | 31 |
| Córdoba | 30 |
| Cundinamarca | 116 |
| Huila | 37 |
| La Guajira | 15 |
| Magdalena | 30 |
| Meta | 29 |
| Nariño | 64 |
| Norte de Santander | 40 |
| Quindío | 12 |
| Risaralda | 14 |
| Santander | 87 |
| Sucre | 26 |
| Tolima | 47 |
| Valle del Cauca | 42 |
| Arauca | 7 |
| Casanare | 19 |
| Putumayo | 13 |
| San Andrés y Providencia | 2 |
| Amazonas | 11 |
| Guainía | 9 |
| Guaviare | 4 |
| Vaupés | 6 |
| Vichada | 4 |
License
This package is open-sourced software licensed under the MIT license.