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.

Corpen automatically records every meaningful user action in a central audit log stored in the Auditoria table. Each time a controller performs a create, update, or delete operation it calls AuditoriaController@create, which writes a timestamped entry that identifies the acting user, the action description, and the module (area) where it occurred. Administrators can review this log in full at /admin to support compliance requirements and troubleshoot unexpected changes.

Route

The audit log is exposed as a resource controller registered at the root admin path:
Route::resource('admin', AuditoriaController::class)
    ->names('admin.auditoria')
    ->middleware(['auth', 'candirect:admin.auditoria.index']);
MethodURIController ActionRoute Name
GET/adminAuditoriaController@indexadmin.auditoria.index
The route is protected by both the auth middleware and the candirect:admin.auditoria.index gate, so only users with the admin.auditoria.index permission can access it.

Database Table: Auditoria

The audit log is persisted in the Auditoria table (note the capital A — this is the value set on the $table property of the auditoria model). The table has no Laravel timestamps columns; all time data is stored in the dedicated fields below.
ColumnTypeDescription
idbigint (auto-increment)Primary key
fechaRegistrodateCalendar date when the action was recorded
horaRegistrotimeClock time when the action was recorded
usuariostringDisplay name of the authenticated user (Auth::user()->name)
accionstringFree-text description of what was done (e.g., "add usuario app maria.lopez")
The usuario_id and area fields are written by AuditoriaController@create at the application layer but are not defined in the 2024_08_02_211212_create_auditorias_table migration. If your database was created solely from migrations those columns will not exist. Ensure your schema is up to date with the codebase before relying on those fields for queries.

How Audit Entries Are Created

Every controller that needs to record an audit event instantiates AuditoriaController via the service container and calls its create method:
private function auditoria($accion)
{
    $auditoriaController = app(AuditoriaController::class);
    $auditoriaController->create($accion, "ADMINISTRACIÓN");
}
The create method itself uses Carbon::now() to capture the current date and time, and reads the user identity from Auth::user():
public function create($action, $area)
{
    $now = Carbon::now();

    auditoria::create([
        'fechaRegistro' => $now->toDateString(),
        'horaRegistro'  => $now->toTimeString(),
        'usuario'       => Auth::user()->name,
        'accion'        => $action,
    ]);
}
The $area parameter is accepted by the method signature (controllers pass values such as "ADMINISTRACIÓN" or "CREDITOS") but the column is not part of the base migration schema — see the note in the Database Table section above. This pattern is used consistently across admin, credits, portfolio, and other modules — the area argument differentiates which part of the system originated the entry.

Viewing the Audit Log

Navigate to /admin when logged in with the admin.auditoria.index permission. The index action retrieves all records sorted newest-first:
public function index()
{
    $registros = auditoria::orderBy('id', 'desc')->get();
    return view('admin.users.usuarios', compact('registros'));
}
The view (admin.users.usuarios) renders the full list of audit records in reverse chronological order, giving administrators an immediate view of the most recent system activity.

Filtering and Searching Audit Records

The base index query returns all records. To narrow results for a specific compliance review, you can query the Auditoria table directly:
// Count actions by a specific user
$count = auditoria::where('usuario', $user->name)->count();

// Get the most recent action for a user
$last = auditoria::where('usuario', $user->name)
    ->orderBy('fechaRegistro', 'desc')
    ->first();
The user edit view at /users/{user}/edit already shows a summary count and the date of the last recorded action for each user, pulled with the same where('usuario', $user->name) pattern.
The AuditoriaController at App\Http\Controllers\AuditoriaController is the system-wide audit log and is separate from AuditoriaProyectosController (App\Http\Controllers\Flujo\AuditoriaProyectosController). The latter is scoped exclusively to the Flujo/workflows module and records project-level task activity — it exposes its own /auditoria route nested inside the Flujo route group and supports PDF export. Do not confuse the two when reviewing records or configuring permissions.
For compliance reporting, pair the fechaRegistro and horaRegistro columns to reconstruct a precise chronological timeline, then export the result set to Excel using maatwebsite/excel. Filter by usuario to scope activity to a specific person. If your schema includes the area column, you can further isolate records by module (e.g., "CREDITOS", "ADMINISTRACIÓN").

Build docs developers (and LLMs) love