<?php

namespace App\Models;

use CodeIgniter\Model;

class ExamRoomModel extends Model
{
    protected $table            = 'exam_rooms';
    protected $primaryKey       = 'id';
    protected $useAutoIncrement = true;
    protected $returnType       = 'array';
    protected $useSoftDeletes   = true;
    protected $allowedFields    = [
        'exam_event_id', 'name', 'capacity'
    ];

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

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