Skip to main content

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.
GET /dependencias
Response
todasDependencias
array
Array of dependency objects with parent-child relationships
estadisticas
object
Count of dependencies by type
{
  "jefatura": 1,
  "direccion": 15,
  "departamental": 25,
  "division": 42,
  "comisaria": 180,
  "seccion": 95,
  "destacamento": 120
}
Example Request
curl -X GET "https://your-domain.com/dependencias" \
  -H "Cookie: your-session-cookie"

Create Section or Station

Create a new section (sección) or station (destacamento).
POST /dependencias
Request Body
nombre
string
required
Dependency name (will be prefixed with “Sección” or “Destacamento”)
tipoDependencia
string
required
Must be: seccion or destacamento
direccion
integer
Direction ID (parent)
departamental
integer
Departamental ID (parent)
division
integer
Division ID (parent)
comisaria
integer
Comisaría ID (parent)
telefono
string
Contact phone number
ubicacion
string
Physical location
observaciones
text
Additional notes
Note: You must provide at least one parent dependency (direccion, departamental, division, or comisaria). Example Request
curl -X POST "https://your-domain.com/dependencias" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Cookie: your-session-cookie" \
  -d "nombre=Técnica 911" \
  -d "tipoDependencia=seccion" \
  -d "division=15" \
  -d "telefono=343-4123456" \
  -d "ubicacion=Av. Almafuerte 123"
Response Redirects to /dependencias with success message: “Dependencia creada exitosamente.” Error Responses
error
string
“Debe elegir al menos una dependencia padre” - No parent dependency selected

Create General Dependency

Create any type of dependency using the general form.
POST /dependencias/store-general
Request Body
nombre
string
required
Dependency name
tipo
string
required
Dependency type: subjefatura, direccion, departamental, division, comisaria, seccion, destacamento, area
parent_id
integer
Parent dependency ID (must be valid for the type)
telefono
string
Phone number
ubicacion
string
Location
observaciones
text
Observations
Hierarchy Validation The system enforces hierarchical rules:
  • 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
Example Request
curl -X POST "https://your-domain.com/dependencias/store-general" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Cookie: your-session-cookie" \
  -d "nombre=911 y Video Vigilancia" \
  -d "tipo=division" \
  -d "parent_id=5" \
  -d "telefono=343-4200000"

Show Dependency

View details of a specific dependency.
GET /dependencias/{id}
id
integer
required
Dependency ID
Response Returns view with dependency details, parent, and children.

Update Dependency

Update an existing dependency.
PUT /dependencias/{id}
id
integer
required
Dependency ID to update
Request Body
nombre
string
required
Dependency name
parent_id
integer
Parent dependency ID (validated against hierarchy rules)
telefono
string
Phone number
ubicacion
string
Location
observaciones
text
Observations
Validations
  • Prevents circular references (a dependency cannot be its own ancestor)
  • Validates hierarchy rules when changing parent
  • Maintains data integrity
Example Request
curl -X PUT "https://your-domain.com/dependencias/42" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Cookie: your-session-cookie" \
  -d "nombre=Sección Técnica 911" \
  -d "telefono=343-4123456, 343-4123457" \
  -d "observaciones=Updated contact information"
Response Redirects to /dependencias with success message: “Dependencia actualizada exitosamente.” Error Responses
error
string
“La nueva jerarquía seleccionada no es válida” - Invalid hierarchy
error
string
“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).
DELETE /dependencias/{id}
id
integer
required
Dependency ID to delete
Restrictions
  • Only seccion and destacamento types can be deleted
  • Cannot delete if it has child dependencies
Response Redirects to /dependencias with success message: “Dependencia eliminada exitosamente.” Error Responses
error
string
“Solo se pueden eliminar secciones y destacamentos.” - Invalid type for deletion
error
string
“No se puede eliminar la dependencia porque tiene dependencias asociadas.” - Has child dependencies

AJAX Endpoints

Get Departamentals

Get departamental dependencies by parent direction.
GET /get-departamentales?direccion_id={id}
direccion_id
integer
required
Direction ID
Response
[
  {
    "id": 12,
    "nombre": "Departamental Paraná",
    "tipo": "departamental",
    "parent_id": 5
  }
]

Get Divisions

Get division dependencies by parent.
GET /get-divisiones?departamental_id={id}
GET /get-divisiones?direccion_id={id}
departamental_id
integer
Departamental ID
direccion_id
integer
Direction ID (if departamental not provided)

Get Comisarías

Get comisaría dependencies by departamental.
GET /get-comisarias?departamental_id={id}
departamental_id
integer
required
Departamental ID

Get Dependencies by Type

Get dependencies filtered by type and optionally by parent.
GET /get-dependencias-por-tipo
tipo
string
required
Dependency type
parent_id
integer
Optional parent ID filter

Get Possible Parents

Get valid parent dependencies for a specific type.
GET /get-posibles-padres?tipo={tipo}
tipo
string
required
Dependency type to get valid parents for
Response Returns array of dependencies that can be parents for the specified type.

Dependency Types

Hierarchy from top to bottom:
  1. Jefatura - Police Headquarters (top level)
  2. Subjefatura - Sub-headquarters
  3. Dirección - Directorate
  4. Departamental - Departmental unit
  5. División - Division
  6. Comisaría - Police station
  7. Sección - Section
  8. Destacamento - Detachment/outpost
  9. Área - Area (can be anywhere in hierarchy)

Model Methods

Get Badge Class

$dependency->getBadgeClass() // Returns CSS class for UI badges
$dependency->getBadgeColor() // Returns hex color code

Check Deletion Permission

$dependency->puedeSerEliminada() // Returns true if can be deleted

Get Hierarchy Path

$dependency->getRutaJerarquica() // Returns array of ancestors
$dependency->dependeDe()         // Returns parent name or default

Get Recursive Children

Destino::obtenerTodosLosHijos($id) // Returns all descendant IDs

Error Codes

400
error
Bad Request - Validation error or missing required fields
401
error
Unauthorized - Authentication required
403
error
Forbidden - Missing permissions (ver-dependencia, crear-dependencia, editar-dependencia, borrar-dependencia)
404
error
Not Found - Dependency not found
422
error
Unprocessable Entity - Invalid hierarchy or circular reference

Models

Destino Model

Represents an organizational dependency. Relationships
  • padre - BelongsTo Destino (parent dependency)
  • hijos - HasMany Destino (child dependencies)
Scopes
  • delTipo($tipo) - Filter by type
  • buscar($texto) - Search by name, phone, or location
Static Methods
  • getEstadisticas() - Get count by type
  • obtenerTodosLosHijos($id) - Get all descendants
Source Code Reference Controller: app/Http/Controllers/DependenciaController.php:1-576 Model: app/Models/Destino.php:1-205

Build docs developers (and LLMs) love