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 visual inspection records the faults that an evaluator identifies during the physical examination of the vehicle — things like body damage, worn tires, cracked glass, or missing safety equipment. Each fault category carries a valoracion weight, and any fault that is present (tiene = 1) subtracts from a perfect score of 1.0. The resulting fallas factor accounts for 35% of the total inspection depreciation, blended with the 65% mechanical factor to produce the final depre_inspeccion coefficient.
The Inspeccion Model
Each fault item in an evaluation produces one row in the inspeccion table:
protected $fillable = [
'id_vehiculo', // FK → vehiculos.id
'nombre', // Fault section name (e.g. "Carrocería", "Vidrios")
'caracteristica', // Specific fault within the section
'tiene', // 1 = fault is present, 0 = not present (cast to boolean)
'valoracion', // Weight deducted when the fault is present (decimal, 4 decimal places)
'observaciones', // Free-text notes
];
protected $casts = [
'tiene' => 'boolean',
'valoracion' => 'decimal:4',
];
| Field | Values | Meaning |
|---|
tiene | true / false | Whether this fault was found during inspection |
valoracion | 0.0000 – 1.0000 | How much this fault reduces the inspection score when present |
The fault catalog that drives the inspection form is stored in the SeccionFalla model. Each catalog entry provides titulo, componente (list of characteristics), and valoracion. Admins configure these sections via GET /secciones/listado.
Configure all fault sections in Secciones before evaluators begin creating appraisals. Changes to the SeccionFalla catalog are reflected immediately in every new inspection form — the catalog is loaded fresh on each visit to the inspection page.
AvaluoController::evaluar_inspeccion() computes the combined inspection factor stored as depre_inspeccion:
public function evaluar_inspeccion($id)
{
$pesoFallas = 35; // weight assigned to visual fault inspection
$pesoTecnica = 65; // weight assigned to mechanical inspection
$inspeccion = Inspeccion::where('id_vehiculo', $id)->get();
$Tecnica = $this->Tecnica($id); // mechanical factor (see Evaluación Mecánica)
$data = $inspeccion->toArray();
$suma = 0;
foreach ($data as $item) {
if ($item['tiene'] == 1) {
$suma += $item['valoracion'];
}
}
$fallas = 1 - $suma;
$total = round(($pesoTecnica * $Tecnica + $pesoFallas * $fallas) / 100, 3);
return $total; // stored as depre_inspeccion on the Avaluo record
}
Step-by-step breakdown:
- Sum the
valoracion of every fault where tiene = 1 (fault is present).
- Subtract from
1.0 to get the fallas factor: fallas = 1 - Σ(valoracion where tiene = 1).
- Blend with the mechanical Tecnica factor using fixed weights:
depre_inspeccion = round((65 × Tecnica + 35 × fallas) / 100, 3)
- Store the result as
depre_inspeccion in the avaluos table.
This factor then feeds directly into the final appraisal value:
valorAvaluo = precio_referencial × depre_inspeccion × depre_modelo × depre_kilometraje × factor_reposicion
Workflow
Creating a New Inspection
InspeccionController@index loads the full SeccionFalla catalog and guards against duplicate submissions:
if (Inspeccion::where('id_vehiculo', $id)->exists()) {
return redirect()->route('resultados.avaluo.continuar', $id)
->with('success', 'Ya se ha realizado la evaluación por Inspección para este vehículo.');
}
$secciones = SeccionFalla::all()->map(function ($seccion) {
return [
'titulo' => $seccion->titulo,
'caracteristicas' => $seccion->componente,
'valoracion' => $seccion->valoracion,
];
});
On submission, InspeccionController@store accepts a flat data[] array from the React form and bulk-inserts all fault rows in a single query:
$data = $request->input('data');
foreach ($data as $item) {
$inspecciones[] = [
'id_vehiculo' => $id,
'nombre' => $item['nombre'],
'caracteristica' => $item['caracteristica'],
'tiene' => $item['tiene'],
'valoracion' => $item['valoracion'],
'observaciones' => $item['observaciones'],
'created_at' => now(),
'updated_at' => now(),
];
}
Inspeccion::insert($inspecciones);
Editing a Saved Inspection
The edit form loads both the current SeccionFalla catalog and the previously saved Inspeccion rows, keying them by nombre__caracteristica:
$evaluados = Inspeccion::where('id_vehiculo', $vehiculo->id)
->get()
->keyBy(fn($i) => $i->nombre . '__' . $i->caracteristica);
This merging strategy means that if the admin adds new fault characteristics to the catalog after an appraisal is created, the new items will appear in the edit form with blank (un-marked) values — the evaluator is prompted to complete them. Updates are applied via Inspeccion::updateOrCreate() keyed on (id_vehiculo, nombre, caracteristica).
Sections Configuration
Admins manage fault sections and their characteristics at GET /secciones/listado. The available operations are:
| Action | Route | Name | Description |
|---|
| View all sections | GET /secciones/listado | secciones.index | Lists SeccionFalla and SeccionTecnica catalogs |
| Update a fault section | POST /secciones/actualizar/{id} | secciones.update | Edit a SeccionFalla entry |
| Update a técnica section | POST /secciones/actualizarTecnica/{id} | secciones.updateTecnica | Edit a SeccionTecnica entry |
Only users with the admin role can access these routes.
Route Reference
| Method | URI | Name | Description |
|---|
GET | /registro/evaluacion/inspeccion/{id} | evaluacion.inspeccion | Display inspection form |
POST | /registro/evaluacion/inspeccion/store/{id} | evaluacion.inspeccion.store | Save new inspection |
GET | /registro/evaluacion/inspeccion/edit/{id} | evaluacion.inspeccion.edit | Display edit form |
POST | /registro/evaluacion/inspeccion/update/{id} | evaluacion.inspeccion.update | Update saved inspection |
GET | /secciones/listado | secciones.index | Admin: manage fault sections |
All registration routes require auth and verified middleware. The InspeccionController enforces VehiculoPolicy::view on read operations and VehiculoPolicy::update on write operations.