'datetime', 'end_time' => 'datetime', 'total_marks' => 'decimal:2', 'obtained_marks' => 'decimal:2', 'correct_answers' => 'integer', 'incorrect_answers' => 'integer', 'is_passed' => 'boolean', 'attempt_number' => 'integer', ]; public function user(): BelongsTo { return $this->belongsTo(User::class); } public function exam(): BelongsTo { return $this->belongsTo(Exam::class); } public function attempt_answers(): HasMany { return $this->hasMany(ExamAttemptAnswer::class); } public function getPercentageAttribute(): float { if ($this->total_marks == 0) { return 0; } return ($this->obtained_marks / $this->total_marks) * 100; } public function getDurationAttribute(): ?int { if ($this->start_time && $this->end_time) { return $this->start_time->diffInMinutes($this->end_time); } return null; } }