public function examLearnerByCourse($courseid) { $exam = Exam::with('members')->whereHas('members', function ($member) { return $member->where('user_id', $this->user->id); })->where('course_id', $courseid)->get(); return $exam; }
public function checkExamTimeout(Exam $exam, $attempt = 1) { $member = $exam->members()->where('user_id', $this->user->id)->first(); if ($member) { if ($member->finished_at->diffInSeconds(Carbon::now(), false) < 0) { return true; } } return false; }