<?php

namespace App\Models;

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

class Quiz extends BaseModel
{
    protected $table = 'quiz';

    public $timestamps = true;

    protected $fillable = [
        'student_id',
        'school_id',
        'class_section_id',
        'updated_by',
        'quiz_index',
        'score',
        'comment',
        'semester',
        'school_year',
        'created_at',
        'updated_at',
    ];

    protected $casts = [
        'student_id'       => 'integer',
        'school_id'        => 'integer',
        'class_section_id' => 'integer',
        'updated_by'       => 'integer',
        'quiz_index'       => 'integer',
        'score'            => 'decimal:2',
        'created_at'       => 'datetime',
        'updated_at'       => 'datetime',
    ];

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

    public function classSection(): BelongsTo
    {
        return $this->belongsTo(ClassSection::class, 'class_section_id');
    }
}
