<?php

namespace App\Models;

use App\Models\BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class SemesterScoreSnapshot extends BaseModel
{
    protected $table = 'semester_score_snapshots';

    protected $fillable = [
        'student_id',
        'school_id',
        'class_section_id',
        'semester',
        'school_year',
        'grading_profile_id',
        'grading_profile_version',
        'calculation_mode',
        'calculation_policy_version',
        'input_json',
        'calculation_json',
        'semester_score',
        'calculated_by',
        'calculated_at',
    ];

    protected $casts = [
        'student_id' => 'integer',
        'school_id' => 'integer',
        'class_section_id' => 'integer',
        'grading_profile_id' => 'integer',
        'input_json' => 'array',
        'calculation_json' => 'array',
        'semester_score' => 'decimal:2',
        'calculated_by' => 'integer',
        'calculated_at' => 'datetime',
    ];

    public function semesterScore(): BelongsTo
    {
        return $this->belongsTo(SemesterScore::class, 'snapshot_id');
    }
}
