<?php

class SipdMasterProgram extends \Phalcon\Mvc\Model
{
    public function initialize()
    {
        $this->setSchema("jaga");
        $this->setSource("sipd_master_program");
        $this->belongsTo("kode_bidang", "SipdMasterBidang", "kode");
        $this->hasManyToMany(
            "id",
            "SipdProgram",
            "id_program",
            "id_skpd",
            "SipdSkpd",
            "id"
        );
    }

    public function toDetail() {
        $result = $this->toArray();

        if(empty($this->SipdMasterBidang)) {
            $result['bidang'] = null;
        } else {
            $result['bidang'] = $this->SipdMasterBidang->toArray();
        }

        return $result;
    }
}
