承接 baironbernal/colombia-locations 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

baironbernal/colombia-locations

最新稳定版本:1.0.0

Composer 安装命令:

composer require baironbernal/colombia-locations

包简介

Paquete con todos los departamentos y municipios de Colombia para Laravel

README 文档

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.

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固