<?php

class PenerimaBos extends \Jaga\Models\BaseModel {
    public $npsn;
    public $tahun;
    public $jenis_salur;

    public function initialize()
    {
        $this->setSchema("jaga");
        $this->setSource("penerima_bos");
    }

    public function getSource()
    {
        return 'penerima_bos';
    }

    public static function isFoundByNpsnTahun($npsn, $tahun): bool
    {
        $isFound = true;
        try {
            $row = parent::findFirst([
                'conditions' => 'npsn LIKE :npsn: AND tahun = :tahun:',
                'bind' => [
                    'npsn' => $npsn,
                    'tahun' => $tahun
                ]
            ]);
            if (!$row) {
                $isFound = false;
            }
        } catch (\Exception $e) {
            $isFound = false;
        }

        return $isFound;
    }
}
