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.

Photographic evidence is a critical part of every vehicle appraisal. After completing the mechanical and inspection steps, evaluators upload images that document the physical condition of the vehicle from multiple angles. These images are stored on the server, linked to the vehicle record, and automatically embedded in the generated PDF report — creating a complete, tamper-evident appraisal package.

The VehiculoImagen Model

Each image is stored as a row in the vehiculo_imagen table, managed by the VehiculoImagen Eloquent model. The model uses soft deletes, so removed images are retained in the database for audit purposes.
// app/Models/VehiculoImagen.php
protected $fillable = [
    'id_vehiculo',   // Foreign key → vehiculos.id
    'lado',          // Shooting angle / position label (e.g. "frontal", "lateral")
    'url',           // Relative path inside the storage disk (e.g. "vehiculos/vehiculo_1_abc123.jpg")
    'descripcion',   // Optional free-text description of the image
    'fecha',         // Date the image was captured / uploaded (cast to date)
];
FieldTypeDescription
id_vehiculointeger (FK)Links the image to a specific vehicle appraisal
ladostringPosition or angle label for the photo
urlstringStorage-relative path used to retrieve the file
descripcionstring | nullOptional notes about what the image shows
fechadateDate the image was uploaded

Routes

All image routes are grouped under the /registro prefix and require authentication (auth, verified middleware).
MethodURINameController MethodPurpose
GET/registro/imagenes/vehiculo/{id}imagenes.vehiculoImagenesController@indexShow the image upload page for a vehicle
POST/registro/imagenes/vehiculo/store/{id}imagenes.vehiculo.storeImagenesController@storeUpload and persist new images
GET/registro/imagenes/vehiculo/edit/{id}imagenes.vehiculo.editImagenesController@editShow the image editing page
POST/registro/imagenes/vehiculo/update/{id}imagenes.vehiculo.updateImagenesController@updateUpdate, add, or remove images

Upload page — GET /registro/imagenes/vehiculo/{id}

The controller checks that the authenticated user is authorized to view the vehicle via its policy. If no images exist yet for the vehicle, the upload view (Registro/create/imagenes_avaluo) is rendered. If images already exist, the user is redirected to the dashboard to prevent accidental duplication.
// ImagenesController@index (simplified)
$vehiculo = Vehiculo::findOrFail($id);
$this->authorize('view', $vehiculo);

if (!VehiculoImagen::where('id_vehiculo', $vehiculo->id)->exists()) {
    return Inertia::render('Registro/create/imagenes_avaluo', compact('id'));
} else {
    return redirect()->route('dashboard');
}

Store images — POST /registro/imagenes/vehiculo/store/{id}

Validated images are iterated, saved to the public storage disk under vehiculos/, and bulk-inserted into vehiculo_imagen. Each file is given a deterministic, collision-safe name. The lado column is populated from the ubicacion field submitted by the form:
$extension     = $file->getClientOriginalExtension();
$nombreArchivo = 'vehiculo_' . $id . '_' . uniqid() . '_' . time() . '.' . $extension;
$rutaArchivo   = Storage::disk('public')->putFileAs('vehiculos', $file, $nombreArchivo);

$imagenesGuardadas[] = [
    'id_vehiculo' => $id,
    'url'         => $rutaArchivo,
    'lado'        => $imagenData['ubicacion'],
    'descripcion' => $imagenData['descripcion'] ?? null,
    'fecha'       => now()->format('Y-m-d'),
    'created_at'  => now(),
    'updated_at'  => now(),
];
On success the user is redirected to the appraisal results page (resultados.avaluo).

Edit & update — GET /registro/imagenes/vehiculo/edit/{id} and POST /registro/imagenes/vehiculo/update/{id}

The edit flow loads all existing images for the vehicle and renders Registro/update/EditImagenes. The update handler reconciles the submitted image list against the database:
  1. Retained images (sent with an id) — only lado and descripcion are updated; the file on disk is unchanged.
  2. New images (sent with a file) — saved to storage and inserted as new rows.
  3. Removed images (exist in the database but absent from the request) — the physical file is deleted from storage and the row is soft-deleted.
// Delete images no longer in the submitted list
foreach ($imagenesAEliminar as $imagenEliminar) {
    if (Storage::disk('public')->exists($imagenEliminar->url)) {
        Storage::disk('public')->delete($imagenEliminar->url);
    }
    $imagenEliminar->delete(); // soft delete — row is retained with deleted_at set
}

Storage

Images are written to the public storage disk, which maps to storage/app/public/ on the server filesystem. The subfolder used is vehiculos/:
storage/app/public/
└── vehiculos/
    ├── vehiculo_1_abc123_1718000000.jpg
    ├── vehiculo_1_def456_1718000001.jpg
    └── ...
When running Avalúo Vehicular with Docker, the storage/app/public directory is mounted as a named Docker volume. This ensures uploaded images survive container restarts and re-deployments without data loss. Make sure the volume is backed up as part of your disaster-recovery plan.

Images in Reports

When a PDF report is generated for an appraisal, all images associated with the vehicle are fetched and embedded directly into the document:
// ArchivoControler – prepararDatosPdf()
$imagenes = VehiculoImagen::where('id_vehiculo', $id)->get();

return array_merge([
    // ... other appraisal data
    'imagenes' => $imagenes,
], $factores);
The Blade view at resources/views/pdf/avaluo.blade.php iterates over $imagenes and renders each one inline, giving recipients a self-contained PDF that does not depend on a live server to display the photos.
Upload images from at least four angles — front, rear, driver side, and passenger side — and add close-up shots of any damage or notable features. A thorough photographic record strengthens the credibility of the appraisal and reduces disputes when the report is reviewed by third parties.

Build docs developers (and LLMs) love