db = \Config\Database::connect(); $this->request = \Config\Services::request(); } protected $table = 'amal'; protected $primaryKey = 'id_amal'; protected $returnType = 'object'; protected $allowedFields = ['id_amal', 'nip', 'bulan', 'tahun', 'sholat_jamaah', 'tilawah', 'sholat_tahajud', 'sholat_dhuha', 'bantu_ortu', 'literasi', 'infaq', 'olahraga', 'hafalan', 'lampiran']; public function getAmal($nip) { return $this->db->table('amal') ->join('guru', 'amal.nip = guru.nip') ->where([ 'amal.nip' => $nip, ]) ->get() ->getResult(); } public function getAmalAll() { return $this->db->table('amal') ->join('guru', 'amal.nip = guru.nip')->get()->getResult(); } public function insert_amal($data) { return $this->db->table($this->table)->insert($data); } public function getById($id) { return $this->where(['id_amal' => $id])->get(); } public function getRekapAmal($bulan, $tahun, $nip) { $builder = $this->db->table($this->table); $builder->select('*') ->where('nip', $nip) ->where('tahun', $tahun) ->where('bulan >=', $bulan - 2) ->where('bulan <=', $bulan) ->orderBy('bulan', 'ASC'); return $builder->get()->getResult(); } }