<?php

class PancekKppbc extends \Phalcon\Mvc\Model
{

    /**
     *
     * @var integer
     */
    public $id;

    /**
     *
     * @var string
     */
    public $nama;

    /**
     *
     * @var integer
     */
    public $id_provinsi;

    /**
     *
     * @var integer
     */
    public $id_kota_kabupaten;

    /**
     *
     * @var string
     */
    public $created_at;

    /**
     *
     * @var string
     */
    public $updated_at;

    /**
     *
     * @var string
     */
    public $deleted_at;

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        $this->setSchema("jaga");
        $this->setSource("pancek_kppbc");
        $this->hasOne(
            'id_provinsi',
            \MasterProvinsi::class,
            'provinsi_code',
            [
                'reusable' => true, // cache related data
                'alias'    => 'provinsi'
            ]
        );
        $this->hasOne(
            'id_kota_kabupaten',
            \MasterKotaKabupaten::class,
            'kota_kabupaten_code',
            [
                'reusable' => true, // cache related data
                'alias'    => 'kota_kabupaten'
            ]
        );

        $this->hasMany(
            'id',
            \PancekKppbcUser::class,
            'kppbc_id',
            [
                'reusable' => true, // cache related data
                'alias' => 'kppbc_users',
                'params' => [
                    'conditions' => 'deleted_at IS NULL',
                    'order' => 'id ASC'
                ],
            ]
        );
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'pancek_kppbc';
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return PancekKppbc[]|PancekKppbc|\Phalcon\Mvc\Model\ResultSetInterface
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return PancekKppbc|\Phalcon\Mvc\Model\ResultInterface
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

}
