Files
alrahma_sunday_school_api/app/Models/FinalScore.php
T
root e13df69885
API CI/CD / Validate (composer + pint) (push) Successful in 3m6s
API CI/CD / Test (PHPUnit) (push) Failing after 4m53s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 59s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
fix unittests issues
2026-07-07 20:56:32 -04:00

54 lines
1.5 KiB
PHP

<?php
namespace App\Models;
class FinalScore extends BaseModel
{
protected $table = 'final_score';
// legacy model didn't specify timestamps behavior; table includes created_at/updated_at.
// If you want Laravel to auto-manage them, keep true (recommended).
public $timestamps = true;
protected $fillable = ['student_id', 'school_id', 'class_section_id', 'updated_by', 'score', 'score_letter', 'comment', 'school_year', 'created_at', 'updated_at', 'semester'];
protected $casts = [
'student_id' => '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 legacy 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;
}
}