Overview
TheMantenimiento model represents maintenance operations performed on assets. It tracks preventive, corrective, and predictive maintenance activities, including assigned personnel, schedules, costs, and validation status.
Model Information
Database table name
App\Models\MantenimientoFillable Fields
The following fields can be mass-assigned:Foreign key reference to the
activos table. The asset being maintained.Foreign key reference to the
users table. The supervisor overseeing this maintenance operation.Foreign key reference to the
users table. The primary technician responsible for this maintenance.Type of maintenance operation. Uses string values from
TipoMantenimiento enum.Possible values:correctivo- Corrective maintenance (fixing issues)predictivo- Predictive maintenance (based on monitoring)preventivo- Preventive maintenance (scheduled)
Foreign key reference to the
reportes table. Links maintenance to an issue report.Important: This field is nullable because preventive maintenance does not require a report, while corrective maintenance typically originates from a report.Date and time when the maintenance operation was opened/started.
Date and time when the maintenance operation was completed/closed.
Current status of the maintenance operation. Uses string values from
EstadoMantenimiento enum.Possible values:pendiente- Pendingen_proceso- In progresscompletado- Completedcancelado- Cancelled
Detailed description of the maintenance work to be performed or that was performed.
Whether the maintenance work has been validated/approved by a supervisor.
Total cost of the maintenance operation, including parts and labor.
Casts
The model automatically casts the following attributes:Relationships
Belongs To
activo
Returns the asset that this maintenance operation is performed on.- Type:
BelongsTo - Related Model:
App\Models\Activo - Foreign Key:
activo_id
supervisor
Returns the user who supervises this maintenance operation.- Type:
BelongsTo - Related Model:
App\Models\User - Foreign Key:
supervisor_id
tecnicoPrincipal
Returns the primary technician assigned to this maintenance operation.- Type:
BelongsTo - Related Model:
App\Models\User - Foreign Key:
tecnico_principal_id
reporte
Returns the report that originated this maintenance (if applicable).- Type:
BelongsTo - Related Model:
App\Models\Reporte - Foreign Key:
reporte_id - Note: This relationship may be null for preventive maintenance
Has Many
sesiones
Returns all work sessions associated with this maintenance operation.- Type:
HasMany - Related Model:
App\Models\SesionesMantenimiento - Foreign Key:
mantenimiento_id
Usage Examples
Creating Preventive Maintenance
Creating Corrective Maintenance from Report
Updating Maintenance Status
Validating Maintenance Work
Querying Maintenance Records
Calculating Total Maintenance Cost for Asset
Getting Maintenance by Technician
Database Schema
Related Models
- Activo - Assets being maintained
- Reporte - Reports that trigger maintenance
- User - Supervisors and technicians
Related Enums
- TipoMantenimiento - Maintenance type enum
- EstadoMantenimiento - Maintenance status enum