'integer', 'school_id' => 'integer', 'class_section_id' => 'integer', 'teacher_id' => 'integer', 'score' => 'decimal:2', // change to 'integer' if score is whole number ]; /* Optional relationships */ public function student() { return $this->belongsTo(Student::class, 'student_id'); } public function teacher() { return $this->belongsTo(User::class, 'teacher_id'); } public function classSection() { return $this->belongsTo(ClassSection::class, 'class_section_id'); } /** * Equivalent of CI getFinalExamScore() */ public static function getFinalExamScore(int $studentId, string $semester, string $schoolYear) { $row = static::query() ->select('score') ->where('student_id', $studentId) ->where('semester', $semester) ->where('school_year', $schoolYear) ->first(); return $row?->score; } }