When an evaluator or admin deletes a vehicle in Avalúo Vehicular, the record is not immediately erased — it is soft-deleted, meaning it is hidden from normal queries but still present in the database with aDocumentation 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.
deleted_at timestamp. The recycle bin (/reciclaje) provides a dedicated interface to browse those hidden records, restore them to their original state, or permanently erase them when they are no longer needed. Evaluators see only their own deleted vehicles; administrators see the full list across all evaluators, along with statistics on how many records were deleted this calendar month.
How Soft Deletes Work
Laravel’sSoftDeletes trait adds a deleted_at column to a model’s table. When $model->delete() is called, Eloquent sets deleted_at to the current timestamp instead of executing a DELETE statement. All standard Eloquent queries automatically add a WHERE deleted_at IS NULL clause, so soft-deleted rows are invisible to the rest of the application until explicitly requested.
To query soft-deleted records, use:
Models That Support Soft Deletes
Both of the core domain models useSoftDeletes:
| Model | Table | Trait |
|---|---|---|
App\Models\Vehiculo | vehiculos | Illuminate\Database\Eloquent\SoftDeletes |
App\Models\Avaluo | avaluo | Illuminate\Database\Eloquent\SoftDeletes |
destroy route, the controller also soft-deletes every related record in a single operation — condicionGeneral, inspecciones, sistemas, accesorios, archivos, imagenes, and avaluo — as well as any AvaluoCompartido entries linked to the vehicle’s appraisal. The same cascade logic runs in reverse during a restore.
Routes
All routes are grouped under the/reciclaje prefix and require the auth and verified middleware.
List Soft-Deleted Records
Vehiculo records using onlyTrashed(), with eager-loaded marca and evaluador relationships. Each record in the response includes:
id,entidad,marca,modelo,año_fabricacion,placafecha_evaluacion,deleted_at(formattedY-m-d)id_evaluador,nombre_evaluador,email_evaluador
usuarios array (unique evaluator IDs and names for filtering) and a stats object with total, eliminados_mes (deleted this month), and por_evaluador counts.
Restore a Record
.withTrashed() so Laravel does not filter out soft-deleted records when resolving the route model. The controller calls Vehiculo::onlyTrashed()->findOrFail($id) and then cascades ->restore() to every related sub-model and the appraisal itself.
AvaluoCompartido rows that were soft-deleted alongside the appraisal are also restored.
Soft Delete (Move to Bin)
Force Delete (Permanent)
.withTrashed() so it can resolve records that have already been soft-deleted.
For archivos and imagenes, the controller additionally deletes the associated files from the public storage disk before force-deleting the database rows:
Restore a Vehicle
Navigate to the recycle bin
Go to
/reciclaje/listado. The page displays a table of all soft-deleted vehicles visible to your account, along with deletion date and the evaluator who owned the record.Find the deleted vehicle
Use the evaluator filter (admins only) or scroll to locate the vehicle by brand, model, plate, or deletion date. The
deleted_at column shows when it was moved to the bin.Click Restore
Click the Restaurar action for the target vehicle. This triggers
GET /reciclaje/restore/{id}, which cascades the restore across the vehicle’s inspections, condition records, systems, accessories, files, images, appraisal, and any shared appraisal links.Operations Reference
| Operation | Route | Access |
|---|---|---|
| List deleted records | GET /reciclaje/listado | Admin (all), Evaluator (own) |
| Restore a record | GET /reciclaje/restore/{id} | Admin (all), Evaluator (own) |
| Soft delete (move to bin) | DELETE /reciclaje/destroy/{id} | Admin (all), Evaluator (own) |
| Permanently delete | DELETE /reciclaje/forceDelete/{id} | Admin only |