<?php

namespace App\Models\Referensi;

use App\Models\BaseModel;

class PdkprovModel extends BaseModel
{
    protected $table            = 'pdk_prov';
    protected $primaryKey       = 'id';
    protected $allowedFields    = ['nama_prov', 'nama_alt', 'kode'];

    public function find_by_id($id)
    {
        $db = \Config\Database::connect();
        $builder = $db->table($this->table);

        //$builder->join('table2', 'table2.fk = pdk_unit.fk');
        $builder->where('id', $id);

        return $builder->get()->getRow();
    }

    function dd_prov()
    {
        $db = \Config\Database::connect();
        $builder = $db->table($this->table);
        $result = $builder->get()->getResult();

        $option[''] = 'Pilih Provinsi...';
        foreach ($result as $res) {
                $option[$res->id] = $res->nama_prov;
        }
        return $option;
    }
}