<?php

namespace App\Models\Referensi;

use App\Models\BaseModel;

class PdkmlayModel extends BaseModel
{
    protected $table            = 'pdk_laym';
    protected $primaryKey       = 'id';
    protected $allowedFields    = ['id_unit', 'uraian', 'sla', 'satuan', 'menit', 'status', 'bobot', 'st', 'linkapp', 'id_user', 'wkt_rekam'];

    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_mlay()
    {
        $db = \Config\Database::connect();
        $builder = $db->table($this->table);
        $result = $builder->get()->getResult();

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