Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/corpentunida-org/corpen/llms.txt

Use this file to discover all available pages before exploring further.

The Associates module is the master registry for all cooperative members — referred to as pastors or associates — within Corpen. It maintains each member’s personal, ministerial, and document-archive record in the mae_asociados table, and provides a complete lifecycle from initial enrollment to ECM (Electronic Content Management) archiving. All routes are protected by the auth middleware and prefixed under /asociados.

Routes Overview

MethodPathNameDescription
GET/asociados/tableroasociados.dashboardDashboard with KPI cards and charts
GET/asociados/maestroasociados.maestro.indexPaginated associate list with search and filters
GET/asociados/maestro/createasociados.maestro.createNew associate form
POST/asociados/maestroasociados.maestro.storeSave new associate record
GET/asociados/maestro/{id}asociados.maestro.showView associate details
GET/asociados/maestro/{id}/editasociados.maestro.editEdit associate form
PUT/PATCH/asociados/maestro/{id}asociados.maestro.updateUpdate associate record
DELETE/asociados/maestro/{id}asociados.maestro.destroyDelete associate record
GET/asociados/sincronizarasociados.sincronizar.indexExcel synchronization panel
GET/asociados/descargar-excelasociados.sincronizar.descargarDownload full database as .xlsx
POST/asociados/subir-excelasociados.sincronizar.subirUpload and preview Excel (Step 1)
POST/asociados/confirmar-sincronizacionasociados.sincronizar.confirmarCommit bulk upsert (Step 2)
GET/asociados/buscar-cedula/{cedula}asociados.buscar-cedulaAJAX lookup by cédula in mae_asociados
GET/asociados/buscar-tercero/{cedula}asociados.buscar-terceroAJAX lookup by cédula in MaeTerceros
GET/asociados/ecmasociados.ecm.indexECM document archive view

Dashboard

The dashboard at GET /asociados/tablero renders key performance indicators derived directly from the mae_asociados table:
  • Total expedientes — full count of all associate records
  • Expedientes activos — records where estado is in ['Activo', 'Vigente']
  • Expedientes inactivos — records where estado is in ['Inactivo', 'Retirado', 'Suspendido']
  • ECM pipeline — counters for escaneado, cargado_ecm, and validado_archivo
  • Pendientes de radicado — records where radicado is null or empty
The five most recently created associates (with their ciudad and distrito relationships) are displayed in the Últimos Ingresos panel. Charts break down members by estado_pastor and estado_civil.

Associate Record Fields

Each record in mae_asociados captures the following groups of data:
FieldTypeNotes
cedulastring(15)Unique national ID (primary lookup key)
nombre1string(100)First name (required)
nombre2string(100)Second name (optional)
apellido1string(100)First surname (required)
apellido2string(100)Second surname (optional)
fecha_nacimientodateDate of birth
lugar_expedicion_cedulastring(50)Municipality of ID issuance
fecha_expediciondateDate the national ID was issued
estado_civilstring(20)Marital status (e.g., Casado, Soltero)

Creating and Editing Associates

The update action applies the 43-field validation ruleset from getValidationRules(). The store action uses the dedicated StoreMaeAsociadoRequest form request class, which enforces the same field rules. Key constraints:
  • cedula must be unique in mae_asociados (unique constraint is relaxed for the record’s own id on update).
  • distrito_actual must exist in MaeDistritos.COD_DIST.
  • ciudad_distrito must exist in geo_ciudades.id_ciudad.
  • Boolean flags (escaneado, cargado_ecm, validado_archivo) are cast from the submitted form value using $request->boolean().
The optional checkbox sincronizar_tercero controls whether saving the associate record also synchronises the corresponding entry in MaeTerceros. When unchecked, the model property skipTerceroSync is set to true before calling save().
// Example: creating an associate from a validated request
$asociado = new MaeAsociado($validated);

if (!$request->boolean('sincronizar_tercero')) {
    $asociado->skipTerceroSync = true;
}

$asociado->save();
The buscar-cedula/{cedula} and buscar-tercero/{cedula} AJAX endpoints are used to auto-fill the create/edit forms. When a user types a cédula, the frontend calls GET /asociados/buscar-cedula/{cedula} to check for an existing associate record, and GET /asociados/buscar-tercero/{cedula} to pre-populate fields from the master MaeTerceros directory. Both endpoints return JSON with a status field of success or error.

Excel Bulk Synchronisation

The synchronisation panel (GET /asociados/sincronizar) enables administrators to upload a master .xlsx file and perform a high-volume upsert against the mae_asociados table without overloading PHP memory or hitting MySQL timeout limits.
1

Navigate to the synchronisation panel

Open GET /asociados/sincronizar (asociados.sincronizar.index). The page offers two actions:
  • Download current databaseGET /asociados/descargar-excel generates a timestamped file named maestro_asociados_YYYY_MM_DD_His.xlsx using AsociadosExport.
  • Upload a new file — use the file picker to select your .xlsx or .xls file (max 50 MB).
2

Upload and validate the Excel file

Submit the form to POST /asociados/subir-excel. The controller:
  1. Validates the file with mimes:xlsx,xls,csv|max:51200.
  2. Reads all rows via AsociadosImport.
  3. Extracts every cedula column, runs a single bulk query against mae_asociados to identify existing records, and builds an in-memory diff.
  4. Cleans each cedula value to digits only (preg_replace('/[^0-9]/', '', ...)).
  5. Detects duplicate cédulas within the uploaded file itself.
  6. Labels each row as CREATE or UPDATE.
  7. Caches the processed rows under key import_asociados_{user_id} for 2 hours.
  8. Returns a preview view (asociados.excel-preview) showing counters for new records, updates, and any row-level warnings.
3

Confirm the import

Review the preview table, optionally correct individual cells inline, then submit to POST /asociados/confirmar-sincronizacion. The controller:
  1. Sets set_time_limit(0) and disables the query log to prevent timeouts.
  2. Applies any manual corrections from the form.
  3. Processes records in chunks of 100, calling DB::reconnect() and wrapping each chunk in its own DB::beginTransaction() / DB::commit() to avoid MySQL error 2006.
  4. Uses firstOrNew(['cedula' => ...]) for upsert semantics.
  5. On success, clears the cache key and redirects to asociados.maestro.index with a success flash message.
  6. On failure, rolls back the current chunk and redirects to the sync panel with the exact SQL error.

ECM Document Archive

The ECM view at GET /asociados/ecm (asociados.ecm.index) provides a filtered interface over the same mae_asociados table, focused on document management state. The header shows three aggregate counters:
  • Digitalizados ECM — count where cargado_ecm = true
  • Pendientes de archivo — count where radicado IS NULL OR radicado = ''
  • Validados — count where validado_archivo = true
The table supports three independent filters applied via query string:
ParameterBehaviour
radicadoExact match on the radicado field
searchLIKE search across cedula, nombre1, and apellido1
estado_digitalizacion1 for digitised, 0 for not digitised (cargado_ecm column)
Results are paginated to 15 records per page with withQueryString() so active filters survive page navigation.

Maestro de Asociados

Full CRUD at /asociados/maestro — manage every field of a member’s personal, ministerial, and document record.

Excel Sync

Bulk import or export the entire associate database via /asociados/sincronizar using transactional chunked processing.

AJAX Lookup

Auto-fill forms at /asociados/buscar-cedula/{cedula} and /asociados/buscar-tercero/{cedula} to prevent duplicate entries.

ECM Archive

Track document digitisation progress and find physical file locations at /asociados/ecm.

Build docs developers (and LLMs) love