Avalúo Vehicular includes a full-featured sharing system that lets evaluators distribute completed appraisals in two distinct modes: internal sharing, where specific registered users are granted access, and public token links, where a unique, unauthenticated URL is generated so anyone with the link can view the appraisal without logging in. Both modes support expiration dates, status lifecycle management, and a per-link view counter.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 AvaluoCompartido Model
Every sharing record is stored in the avaluo_compartido table, managed by the AvaluoCompartido Eloquent model. Each row represents one user’s access grant to one appraisal.
| Field | Type | Description |
|---|---|---|
avaluo_id | integer (FK) | The appraisal being shared |
user_id | integer (FK) | The user receiving access |
token | string | null | Unique 40-character token for public links; null for internal shares |
fecha_inicio | datetime | When the access period begins |
fecha_fin | datetime | null | When the access expires; null means no expiry |
estado | enum | activo, vencido, or renovado |
fecha_compartido | datetime | Created / last renewed timestamp |
motivo | string | Reason for sharing; "acceso publico" triggers token generation |
contador_vistas | integer | Incremented on each public-link page load |
observaciones | string | null | Optional notes visible to the sharer |
Routes
Authenticated sharing routes live under the/avaluo prefix (middleware auth, verified). The public view route has no authentication middleware.
| Method | URI | Name | Controller | Purpose |
|---|---|---|---|---|
GET | /avaluo/share | avaluo.share.index | ShareController@index | List shared appraisals (mine + shared with me) |
POST | /avaluo/share/{id} | avaluo.share.store | ShareController@store | Share an appraisal with one or more users |
POST | /avaluo/share/update/{id} | avaluo.share.update | ShareController@update | Update sharing settings (dates, estado, motivo) |
POST | /avaluo/share/renovar/{id} | avaluo.share.renovar | ShareController@renovar | Renew an expired sharing record |
DELETE | /avaluo/share/destroy/{id} | avaluo.share.destroy | ShareController@destroy | Remove a sharing record |
GET | /avaluo/publico/{token} | avaluo.publico | AvaluoPublicoController@verPublico | View appraisal via public token (no auth required) |
Sharing Workflow
Complete an appraisal
Ensure all steps of the appraisal are finished: vehicle registration, mechanical evaluation, visual inspection, accessories, and image upload. Only completed appraisals should be shared.
Go to the sharing dashboard
Navigate to
/avaluo/share. You will see a summary of all appraisals you have shared and all appraisals that have been shared with you, along with statistics for total, active, expired, renewed, and token-linked shares.Initiate a share
Click the share action on an appraisal. This opens a form that posts to
POST /avaluo/share/{id}.Select users and set the reason
Choose one or more registered users to grant access. Set the
motivo field to describe the purpose. To generate a public link, set motivo to exactly "acceso publico" — this triggers automatic token generation.Set the access window
Provide
fecha_inicio and optionally fecha_fin. Leaving fecha_fin empty grants indefinite access. When fecha_fin is in the past at the time of a public-link visit, the estado is automatically updated to vencido and access is denied.Public Access via Token
Whenmotivo is set to "acceso publico", the system generates a 40-character cryptographically random token using Str::random(40). The resulting public URL is:
routes/web.php, making it fully accessible to unauthenticated visitors:
AvaluoPublicoController@verPublico validates the token on every request:
- Looks up the
AvaluoCompartidorecord bytoken— 404 if not found. - Checks that
estadoisactivoorrenovado— 403 otherwise. - Checks that
fecha_finis not in the past — if it is, updatesestadotovencidoand returns 403. - Increments
contador_vistas. - Renders the full public appraisal view, including all depreciation factors recalculated live.
Sharing Status Lifecycle
Each sharing record moves through a defined state machine:| Estado | Meaning | Access Granted |
|---|---|---|
activo | Currently within the access window | ✅ Yes |
vencido | Access window has expired or was manually revoked | ❌ No |
renovado | Previously expired, renewed with a new fecha_fin | ✅ Yes |
POST /avaluo/share/renovar/{id}, which sets estado = 'renovado', updates fecha_fin, and refreshes fecha_compartido to now().
Admin vs. Evaluator Views
ShareController@index adapts its response based on the authenticated user’s role.
Admin
- The
compartidoscollection passed to the view contains allAvaluoCompartidorecords across the entire system. misCompartidoscontains only the records for avaluos belonging to the admin’s own vehicles.compartidosConmigois empty for admins — admins are not recipients of shared appraisals.- Statistics (
total,activos,vencidos,renovados,conToken) are computed over the fullcompartidoscollection.
- Mis compartidos (
tipo: compartido_por_mi) — appraisals belonging to the evaluator’s own vehicles that they have shared with others. - Compartidos conmigo (
tipo: compartido_conmigo) — appraisals owned by other evaluators that have been shared with them (matched byuser_id). - Each “shared with me” record is decorated with the
propietario(the owning evaluator) for display.
Statistics Dashboard
Thestats array returned to the view provides a quick summary for the sharing dashboard:
| Key | Description |
|---|---|
total | Total sharing records visible to the current user |
activos | Records with estado = 'activo' |
vencidos | Records with estado = 'vencido' |
renovados | Records with estado = 'renovado' |
conToken | Records that have a non-null token (public links) |
misCompartidos | Count of appraisals shared by the current user |
compartidosConmigo | Count of appraisals shared with the current user (0 for admins) |
Required Permissions
Certain sharing actions are protected by explicit permission checks using Spatie Laravel Permission:| Action | Required Permission |
|---|---|
Update sharing settings (update) | update_avaluocompartido |
Renew a sharing (renovar) | update_avaluocompartido |
Delete a sharing (destroy) | delete_avaluocompartido |
The owner of an appraisal cannot share it with themselves. The
store action filters out the appraisal owner’s user ID from any submitted user_ids array before creating records. If the owner is the only user selected, the request is rejected with an explanatory error message rather than creating a no-op record.