'date', 'end_date' => 'date', 'cost' => 'decimal:2', ]; /** * Get the asset that is being maintained. */ public function asset() { return $this->belongsTo(Asset::class); } /** * Get the user who created this maintenance record. */ public function creator() { return $this->belongsTo(User::class, 'created_by'); } /** * Scope a query to only include scheduled maintenances. */ public function scopeScheduled($query) { return $query->where('status', 'scheduled'); } /** * Scope a query to only include in-progress maintenances. */ public function scopeInProgress($query) { return $query->where('status', 'in_progress'); } /** * Scope a query to only include completed maintenances. */ public function scopeCompleted($query) { return $query->where('status', 'completed'); } /** * Scope a query to only include cancelled maintenances. */ public function scopeCancelled($query) { return $query->where('status', 'cancelled'); } }