<?php

namespace App\Models;

use CodeIgniter\Model;

class ExamScheduleModel extends Model
{
    protected $table            = 'exam_schedules';
    protected $primaryKey       = 'id';
    protected $useAutoIncrement = true;
    protected $returnType       = 'array';
    protected $useSoftDeletes   = false;
    protected $allowedFields    = [
        'exam_event_id', 'exam_date', 'exam_day', 'subject_list'
    ];

    protected $useTimestamps = true;
    protected $createdField  = 'created_at';
    protected $updatedField  = 'updated_at';

    public function getSchedulesByEvent($eventId)
    {
        return $this->where('exam_event_id', $eventId)
            ->orderBy('exam_date', 'ASC')
            ->findAll();
    }
}
