58 lines
1.4 KiB
PHP
58 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
use Codeigniter\HTTP\RequestInterface;
|
|
|
|
class ModelGuru extends Model
|
|
{
|
|
|
|
protected $db;
|
|
protected $request;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->db = \Config\Database::connect();
|
|
$this->request = \Config\Services::request();
|
|
}
|
|
|
|
protected $table = 'guru';
|
|
protected $primaryKey = 'nip';
|
|
protected $returnType = 'object';
|
|
protected $allowedFields = ['nip', 'nama_guru', 'tanggal_lahir', 'jenis_kelamin', 'alamat', 'jabatan', 'username', 'password', 'hak_akses', 'is_aktif'];
|
|
|
|
public function getGuru()
|
|
{
|
|
return $this->where(['is_aktif' => 1])->get()->getResult();
|
|
}
|
|
public function getGuru2()
|
|
{
|
|
return $this->where(['is_aktif' => 0])->get()->getResult();
|
|
}
|
|
|
|
public function insert_guru($data)
|
|
{
|
|
return $this->db->table($this->table)->insert($data);
|
|
}
|
|
|
|
public function getById($id)
|
|
{
|
|
return $this->where(['nip' => $id])->get();
|
|
}
|
|
|
|
public function cekUsername($username)
|
|
{
|
|
return $this->where('username', $username)->get();
|
|
}
|
|
|
|
public function check_nip_exists($nip)
|
|
{
|
|
return $this->where('nip', $nip)->countAllResults() > 0;
|
|
}
|
|
|
|
public function check_username_exists($username)
|
|
{
|
|
return $this->where('username', $username)->countAllResults() > 0;
|
|
}
|
|
} |