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 Visits module provides Corpen staff with a lightweight, dedicated area for logging and reviewing in-person visits by cooperative members and clients. Staff can search for a member by name or ID using an AJAX endpoint before registering a visit, and all visit records are accessible through both a paginated dashboard and a full CRUD resource.

Route Group

All routes are grouped under /visitas and protected by the auth middleware. Named routes use the visitas. prefix.
Route::middleware('auth')
    ->prefix('visitas')
    ->name('visitas.')
    ->group(function () {
        Route::get('/cliente/buscar', [VisitaCorpenController::class, 'buscarCliente'])
            ->name('cliente.buscar');

        Route::get('tablero', [VisitaCorpenController::class, 'index'])
            ->name('tablero');

        Route::resource('corpen', VisitaCorpenController::class)
            ->names([
                'index'   => 'corpen.index',
                'create'  => 'corpen.create',
                'store'   => 'corpen.store',
                'show'    => 'corpen.show',
                'edit'    => 'corpen.edit',
                'update'  => 'corpen.update',
                'destroy' => 'corpen.destroy',
            ])
            ->parameters(['corpen' => 'visitaCorpen']);
    });

Routes Reference

MethodURLNameDescription
GET/visitas/cliente/buscarvisitas.cliente.buscarAJAX client search for autocomplete
GET/visitas/tablerovisitas.tableroPaginated visit dashboard
GET/visitas/corpenvisitas.corpen.indexFull list of visit records
GET/visitas/corpen/createvisitas.corpen.createNew visit form
POST/visitas/corpenvisitas.corpen.storeSave new visit
GET/visitas/corpen/{visitaCorpen}visitas.corpen.showView single visit (JSON)
GET/visitas/corpen/{visitaCorpen}/editvisitas.corpen.editEdit visit form
PUT/visitas/corpen/{visitaCorpen}visitas.corpen.updateUpdate visit
DELETE/visitas/corpen/{visitaCorpen}visitas.corpen.destroyDelete visit

Controller: VisitaCorpenController

Namespace: App\Http\Controllers\Vistas\VisitaCorpenController The controller uses the VisitaCorpen model (namespace App\Models\Vistas\VisitaCorpen) and the MaeTerceros model for the client search.

Dashboard (index)

GET /visitas/tablero loads all visits with their associated client, sorted by fecha descending, and paginates at 15 records per page. Optional query parameters for filtering:
ParameterColumnNotes
ciudadbancoThe underlying DB column is banco; the UI label is ciudad
fechafechaFilters to an exact date (whereDate)
GET /visitas/tablero?ciudad=Bogotá&fecha=2025-02-14

Client Search (buscarCliente)

GET /visitas/cliente/buscar accepts a query parameter and performs a case-insensitive search on both cod_ter (member ID) and nom_ter (name) in mae_terceros, returning up to 10 results.
GET /visitas/cliente/buscar?query=garcia
Response:
[
  { "cod_ter": "10234567", "nom_ter": "GARCIA LOPEZ CARLOS ANDRES" },
  { "cod_ter": "10987654", "nom_ter": "GARCIA RUIZ ANA MARIA" }
]

Creating a Visit

1

Search for the member

Before opening the create form, staff can look up the client via the AJAX endpoint. Provide at least a partial name or member ID in the query parameter:
GET /visitas/cliente/buscar?query=10234567
The response supplies the cod_ter (member ID) needed for the visit record.
2

Open the new visit form

Navigate to GET /visitas/corpen/create. Use the client data returned from the search to populate the member identification field.
GET /visitas/corpen/create
3

Submit the visit record

Post to POST /visitas/corpen. Required and optional fields validated by store():
// VisitaCorpenController@store validation
'cedula'         => 'required|string',          // FK → mae_terceros.cod_ter
'banco'          => 'required|string|max:255',  // City / branch (stored as 'banco' in DB)
'motivo'         => 'nullable|string',
'registrado_por' => 'required|string|max:255',  // Name of the staff member logging the visit
The model’s static registrar() method is called internally:
$visita = VisitaCorpen::registrar(
    $request->cedula,
    $request->ciudad,
    $request->motivo,
    $request->registrado_por,
);
A successful store returns a 201 JSON response with the newly created visit.
4

Confirm on the dashboard

Return to GET /visitas/tablero to verify the entry. The dashboard sorts visits by fecha descending so the newest record appears at the top.

Updating a Visit

Submit a PUT request to /visitas/corpen/{visitaCorpen}. Only the fields banco (city), motivo, and registrado_por are accepted for update:
// VisitaCorpenController@update validation
'ciudad'         => 'nullable|string|max:255',
'motivo'         => 'nullable|string',
'registrado_por' => 'nullable|string|max:255',
The client search autocomplete endpoint (GET /visitas/cliente/buscar?query=...) is the primary entry point for staff to identify members before logging a visit. It queries mae_terceros — the shared member master table — using a LIKE search on both cod_ter and nom_ter, so partial names and partial IDs both work. Results are limited to 10 records to keep the response fast.

Build docs developers (and LLMs) love