<?php

namespace App\Models;

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

class ExamPaper extends Model
{
    use BelongsToBranch;

    protected $fillable = [
        'branch_id', 'exam_id', 'class_id', 'subject_id',
        'total_marks', 'passing_marks', 'exam_date',
    ];

    protected function casts(): array
    {
        return ['total_marks' => 'decimal:2', 'passing_marks' => 'decimal:2', 'exam_date' => 'date'];
    }

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

    public function schoolClass(): BelongsTo
    {
        return $this->belongsTo(SchoolClass::class, 'class_id');
    }

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