<?php
namespace App\Models;
use Core\Model;

class ApiMk extends Model
{
    protected $table = 'tb_mk';

    public function getData($idKurikulum = null)
    {
        // filter id_kurikulum selain 1 dan 2
        $where = "WHERE id_kurikulum NOT IN (1,2)";
        $params = [];

        if ($idKurikulum) {
            $where .= " AND id_kurikulum = ?";
            $params[] = $idKurikulum;
        }

        $sql = "SELECT 
                    kode_mk,
                    nama_mk,
                    sks,
                    smt,
                    id_prodi,
                    id_kurikulum
                FROM {$this->table} 
                $where 
                ORDER BY smt, kode_mk";

        return $this->query($sql, $params)->fetchAll();
    }
}
