Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/alber1802/AvaluoVehicular/llms.txt

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

The dashboard is the central hub of Avalúo Vehicular. Every time an authenticated user lands on GET /dashboard, the server computes live KPI figures, assembles the complete vehicle list with progress metadata, and passes everything to the React front-end in a single Inertia response. From here, evaluators can scan pending work, spot vehicles that still need attention, and jump directly into any step of an appraisal — all without leaving the page.

KPI Cards

The StatsCards React component renders animated metric cards derived from the data the DashboardController sends down:
Inertia propLabelHow it is computed
vehiculosHoyVehículos Evaluados HoyVehiculo::whereDate('created_at', now()->toDateString())->count() — scoped to the evaluator when not admin
comparacionAyerComparación vs. ayerSame query shifted one day back; displayed as a trend figure on the card
vehiculosVehículos TotalesFull vehicle collection owned by the user (or all records for admin)
avaluosAvalúos CompletadosCount of rows in the avaluos table that belong to the user’s vehicles
valoracionPromedioValor Promedio de AvalúoSUM(final_estimacion) / COUNT(avaluos); defaults to 0 when no appraisals exist yet
pendientesInformes Pendientesmax(0, count_vehiculos - count_avaluos) — vehicles registered but without a completed appraisal
The “Valor Promedio” card renders the value in dollars ($us) with two decimal places, calculated server-side as:
$valoracionPromedio = $count_avaluos > 0 ? $valoracion / $count_avaluos : 0;
$pendientes         = max(0, $count_vehiculos - $count_avaluos);

Vehicle List

Below the KPI cards is a full vehicle list built from a single eager-loaded query:
$baseQuery = Vehiculo::with('imagenes', 'marca', 'avaluo', 'evaluador', 'inspecciones', 'sistemas')
    ->orderBy('created_at', 'desc');

if (! $isAdmin) {
    $baseQuery->where('id_evaluador', $userId);
}

$vehiculos = $baseQuery->get()->map(function ($v) { /* progress mapping */ });
Each row in the list shows the vehicle’s brand, model, year, evaluator name, license plate, and current appraisal progress. The filter select boxes expose three axes:
  • Brand (id_marca) — populated from MarcaVehiculo::all()
  • Year (año_fabricacion) — distinct years ordered descending
  • Evaluator (id) — list of users; admins see all users ordered by name, evaluators see all non-admin users excluding themselves
All search and filtering logic runs entirely client-side inside the React evaluation-filters component. No additional HTTP request is made when a user types in the search box or changes a filter — the full dataset is already in memory, which keeps interaction instant regardless of list size.

Progress Tracking

Before returning the vehicle collection, DashboardController maps a progreso object onto every vehicle. The three steps and the percentage are derived purely from relationship counts:
$pasos = [
    ['label' => 'Inspección de fallas',   'done' => $v->inspecciones->count() > 0],
    ['label' => 'Sistemas / Mecánica',     'done' => $v->sistemas->count() > 0],
    ['label' => 'Imágenes del vehículo',   'done' => $v->imagenes->count() > 0],
];

$completados = collect($pasos)->where('done', true)->count();
$porcentaje  = round(($completados / count($pasos)) * 100);

$v->progreso = [
    'porcentaje' => $porcentaje,
    'pasos'      => $pasos,
];
The ProgressBar React component renders the percentage as a visual bar alongside the step labels, making it easy to identify exactly which step is still outstanding.
StepRelation checkedTable
Inspección de fallasinspeccionesinspeccion
Sistemas / Mecánicasistemassistemas
Imágenes del vehículoimagenesvehiculo_imagen

Admin vs. Evaluator View

The controller reads Auth::user()->hasRole('admin') once and branches every query accordingly: Admin (isAdmin = true)
  • KPI queries run without a WHERE id_evaluador clause — figures reflect the entire platform.
  • The vehicle list includes all vehicles from all evaluators.
  • The evaluator filter dropdown contains every registered user, ordered by name.
Evaluator (isAdmin = false)
  • All queries are scoped to WHERE id_evaluador = Auth::id().
  • The avaluos count uses a nested whereHas to join through vehiculo:
    Avaluo::whereHas('vehiculo', fn ($q) => $q->where('id_evaluador', $userId))->count();
    
  • The evaluator filter shows all non-admin users except the evaluator themselves, useful when searching by colleague.

Route Reference

MethodURINameMiddlewareController method
GET/dashboarddashboardauth, verifiedDashboardController@index

Build docs developers (and LLMs) love