<?php

namespace App\Controllers;

use App\Models\Home_model;
use CodeIgniter\Database\Exceptions\DatabaseException;

class Home extends BaseController
{
    private $Home_model;
    public function __construct()
    {
        $this->Home_model = new Home_model();
    }

    public function home(): string
    {
        $setting = $this->appSetting();
        $countsiswa = $this->Home_model->count_siswa();
        $countlulus = $this->Home_model->count_keterangan('LULUS');
        $countbelum = $this->Home_model->count_keterangan('BELUM LULUS');
        $counttidak = $this->Home_model->count_keterangan('TIDAK LULUS');
        $data = [
            // 'nama_user' => $user->nama,
            'setting' => $setting,
            'title' => 'Dashboard',
            'countsiswa' => $countsiswa,
            'countlulus' => $countlulus,
            'countbelum' => $countbelum,
            'counttidak' => $counttidak
        ];
        return view('Admin/Home/index', $data);
    }
    public function getlog()
    {
        $data = $this->Home_model->get_log();
        return $this->response->setJSON($data);
    }
}
