'date', 'completion_date' => 'date', 'score' => 'decimal:2', 'is_passed' => 'boolean', ]; /** * Get the employee for this training assignment. */ public function employee() { return $this->belongsTo(User::class, 'employee_id'); } /** * Get the training program for this assignment. */ public function trainingProgram() { return $this->belongsTo(TrainingProgram::class); } /** * Get the user who assigned this training. */ public function assigner() { return $this->belongsTo(User::class, 'assigned_by'); } /** * Get the assessment results for this employee training. */ public function assessmentResults() { return $this->hasMany(EmployeeAssessmentResult::class); } /** * Scope a query to only include assigned trainings. */ public function scopeAssigned($query) { return $query->where('status', 'assigned'); } /** * Scope a query to only include in-progress trainings. */ public function scopeInProgress($query) { return $query->where('status', 'in_progress'); } /** * Scope a query to only include completed trainings. */ public function scopeCompleted($query) { return $query->where('status', 'completed'); } /** * Scope a query to only include failed trainings. */ public function scopeFailed($query) { return $query->where('status', 'failed'); } /** * Scope a query to only include passed trainings. */ public function scopePassed($query) { return $query->where('is_passed', true); } }