<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class MKota extends Model
{
    use HasFactory;

    protected $table = "m_kota";
    protected $primaryKey = 'id_kota';
    public $timestamps = false;
    protected $fillable = [
    ];
    public static function checkExist($id)
    {
        return self::where('id_kota',$id);
    }
    public static function select_q($id_kota,$id_provinsi){
        $query = "SELECT m_kota.* from m_kota";
        $query .= " where m_kota.deleted = 1";
        if ($id_provinsi != 0)
        {
            $query .= " and m_kota.id_provinsi = ".$id_provinsi;
        }
        if ($id_kota != 0)
        {
            $query .= " and m_kota.id_kota = ".$id_kota;
        }
        return DB::select($query);
    }
}
