<?php

namespace App\Models;

use CodeIgniter\Model;

class KrsModel extends Model
{
    protected $table            = 'krs';
    protected $primaryKey       = 'id';
    protected $useAutoIncrement = true;
    protected $returnType       = 'array';
    protected $useSoftDeletes   = false;
    protected $protectFields    = true;
    protected $allowedFields    = [
        'mahasiswa_id',
        'tahun_akademik_id',
        'status',
        'catatan'
    ];

    // Dates
    protected $useTimestamps = true;
    protected $dateFormat    = 'datetime';
    protected $createdField  = 'created_at';
    protected $updatedField  = 'updated_at';

    public function getKrsMahasiswa($mahasiswa_id, $tahun_akademik_id)
    {
        return $this->where('mahasiswa_id', $mahasiswa_id)
                    ->where('tahun_akademik_id', $tahun_akademik_id)
                    ->first();
    }
}
