Overview
The Dependencies API (Dependencias) manages the organizational hierarchy of police departments and units. It supports hierarchical structures from headquarters down to individual stations and sections, with parent-child relationships.Endpoints
List Dependencies
Retrieve all dependencies ordered by hierarchy and name.Array of dependency objects with parent-child relationships
Count of dependencies by type
Create Section or Station
Create a new section (sección) or station (destacamento).Dependency name (will be prefixed with “Sección” or “Destacamento”)
Must be: seccion or destacamento
Direction ID (parent)
Departamental ID (parent)
Division ID (parent)
Comisaría ID (parent)
Contact phone number
Physical location
Additional notes
/dependencias with success message: “Dependencia creada exitosamente.”
Error Responses
“Debe elegir al menos una dependencia padre” - No parent dependency selected
Create General Dependency
Create any type of dependency using the general form.Dependency name
Dependency type: subjefatura, direccion, departamental, division, comisaria, seccion, destacamento, area
Parent dependency ID (must be valid for the type)
Phone number
Location
Observations
- Subjefatura can have parent: jefatura
- Dirección can have parent: jefatura, subjefatura
- Departamental can have parent: jefatura, direccion
- División can have parent: jefatura, direccion, departamental
- Comisaría can have parent: departamental
- Sección can have parent: direccion, departamental, division, comisaria
- Destacamento can have parent: departamental, division, comisaria
- Área can have any dependency as parent
Show Dependency
View details of a specific dependency.Dependency ID
Update Dependency
Update an existing dependency.Dependency ID to update
Dependency name
Parent dependency ID (validated against hierarchy rules)
Phone number
Location
Observations
- Prevents circular references (a dependency cannot be its own ancestor)
- Validates hierarchy rules when changing parent
- Maintains data integrity
/dependencias with success message: “Dependencia actualizada exitosamente.”
Error Responses
“La nueva jerarquía seleccionada no es válida” - Invalid hierarchy
“No se puede establecer esta dependencia como padre porque crearía una referencia circular” - Circular reference detected
Delete Dependency
Delete a section or station (only these types can be deleted).Dependency ID to delete
- Only
seccionanddestacamentotypes can be deleted - Cannot delete if it has child dependencies
/dependencias with success message: “Dependencia eliminada exitosamente.”
Error Responses
“Solo se pueden eliminar secciones y destacamentos.” - Invalid type for deletion
“No se puede eliminar la dependencia porque tiene dependencias asociadas.” - Has child dependencies
AJAX Endpoints
Get Departamentals
Get departamental dependencies by parent direction.Direction ID
Get Divisions
Get division dependencies by parent.Departamental ID
Direction ID (if departamental not provided)
Get Comisarías
Get comisaría dependencies by departamental.Departamental ID
Get Dependencies by Type
Get dependencies filtered by type and optionally by parent.Dependency type
Optional parent ID filter
Get Possible Parents
Get valid parent dependencies for a specific type.Dependency type to get valid parents for
Dependency Types
Hierarchy from top to bottom:- Jefatura - Police Headquarters (top level)
- Subjefatura - Sub-headquarters
- Dirección - Directorate
- Departamental - Departmental unit
- División - Division
- Comisaría - Police station
- Sección - Section
- Destacamento - Detachment/outpost
- Área - Area (can be anywhere in hierarchy)
Model Methods
Get Badge Class
Check Deletion Permission
Get Hierarchy Path
Get Recursive Children
Error Codes
Bad Request - Validation error or missing required fields
Unauthorized - Authentication required
Forbidden - Missing permissions (ver-dependencia, crear-dependencia, editar-dependencia, borrar-dependencia)
Not Found - Dependency not found
Unprocessable Entity - Invalid hierarchy or circular reference
Models
Destino Model
Represents an organizational dependency. Relationshipspadre- BelongsTo Destino (parent dependency)hijos- HasMany Destino (child dependencies)
delTipo($tipo)- Filter by typebuscar($texto)- Search by name, phone, or location
getEstadisticas()- Get count by typeobtenerTodosLosHijos($id)- Get all descendants
app/Http/Controllers/DependenciaController.php:1-576
Model: app/Models/Destino.php:1-205