<?php

namespace App\Models;

use App\Models\Concerns\BelongsToBranch;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Mark extends Model
{
    use BelongsToBranch;

    protected $fillable = [
        'branch_id', 'exam_id', 'student_id', 'class_id', 'subject_id',
        'obtained_marks', 'is_absent', 'remarks', 'marked_by',
    ];

    protected function casts(): array
    {
        return ['obtained_marks' => 'decimal:2', 'is_absent' => 'boolean'];
    }

    public function student(): BelongsTo
    {
        return $this->belongsTo(Student::class);
    }

    public function subject(): BelongsTo
    {
        return $this->belongsTo(Subject::class);
    }

    public function exam(): BelongsTo
    {
        return $this->belongsTo(Exam::class);
    }
}
