Files
alrahma_sunday_school/app/Models/FinalScoreModel.php
T
root 716cc8b8d3
Tests / PHPUnit (push) Failing after 1m20s
fix school year for all tables
2026-07-18 14:45:38 -04:00

48 lines
1.4 KiB
PHP

<?php
namespace App\Models;
use CodeIgniter\Model;
use App\Models\Concerns\SchoolYearAutoFillTrait;
class FinalScoreModel extends Model
{
use SchoolYearAutoFillTrait;
protected $table = 'final_score';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $allowedFields = [
'student_id',
'school_id',
'class_section_id',
'updated_by',
'score',
'score_letter',
'comment',
'semester',
'school_year',
'created_at',
'updated_at'
];
protected $validationRules = [
'school_year' => 'required|string|max_length[9]',
];
// Function to get the final exam score for a specific student, semester, and school year
public function getFinalExamScore($studentId, $semester, $schoolYear)
{
// Query the final_score table for the final exam score based on student ID, semester, and school year
$result = $this->select('score') // We only need the score
->where('student_id', $studentId)
->where('semester', $semester)
->where('school_year', $schoolYear)
->first(); // Get the first matching result
// Return the score, or null if no result is found
return $result ? $result['score'] : null;
}
}