hi, i just try to make attandance app for my school library but my app cant find my model when i call it in controler.
here is my controler
and this is my model
here is my controler
Code:
<?php
namespace App\Controllers;
use app\Models\AbsenModel;
use app\Models\SiswaModel;
class absen extends BaseController
{
protected $absenmodel;
protected $siswamodel;
public function __construct()
{
$this->absenmodel = new AbsenModel();
$this->siswamodel = new SiswaModel();
}
public function index(): string
{
return view('perpus/Dashboard.php');
}
public function save()
{
$ids = $this->request->getvar('ids');
$date = now();
$nama = $this->siswamodel->getnama($ids);
$kelas = $this->siswamodel->getkelas($ids);
$this->absenmodel->save([
'idsiswa' => $ids,
'nama' => $nama,
'kelas' => $kelas,
'date' => $date
]);
return redirect()->to('/Absensi');
}
public function absensi()
{
$data =
[
'absen' => $this->absenmodel->getuser()
];
return view('perpus/viewabsen', $data);
}
}and this is my model
Code:
<?php
namespace App\Models;
use CodeIgniter\Model;
class AbsenModel extends Model
{
protected $table = 'absen';
protected $useTimestamps = true;
protected $allowedFields = ['idsiswa', 'nama', 'kelas', 'date'];
public function getuser($id = false)
{
if ($id == false) {
return $this->findAll();
}
return $this->where(['id' => $id])->nama();
}
}
![[Image: smpz326.png]](http://i.imgur.com/smpz326.png)