'required|string|max_length[9]', ]; protected $validationMessages = []; protected $skipValidation = false; protected $cleanValidationRules = true; // Callbacks protected $allowCallbacks = true; protected $beforeInsert = []; protected $afterInsert = []; protected $beforeUpdate = []; protected $afterUpdate = []; protected $beforeFind = []; protected $afterFind = []; protected $beforeDelete = []; protected $afterDelete = []; // Function to get the midterm exam score for a specific student, semester, school year, and class section public function getMidtermExamScore($studentId, ?string $semester, $schoolYear, ?int $classSectionId = null) { $builder = $this->select('score') ->where('student_id', $studentId) ->where('school_year', $schoolYear); if ($semester !== null && $semester !== '') { $builder->where('semester', $semester); } if ($classSectionId !== null) { $builder->where('class_section_id', $classSectionId); } $result = $builder->first(); return $result ? $result['score'] : null; } }