<?php

namespace App\Models;

use CodeIgniter\Model;

class AbsensiModel extends Model
{
    protected $table            = 'tb_absensi';
    protected $primaryKey       = 'id_absensi';
    protected $useAutoIncrement = true;
    protected $returnType       = 'array';

    protected $allowedFields    = [
        'id_karyawan',
        'tanggal_absensi',
        'jam_masuk_absensi',
        'jam_keluar_absensi',
        'total_jam_kerja_absensi',
        'sesi',
    ];

    protected $useTimestamps = false;

    public function getAbsensiWithKaryawan()
    {
        return $this->select('tb_absensi.*, tb_karyawan.nama_karyawan')
                    ->join('tb_karyawan', 'tb_karyawan.id_karyawan = tb_absensi.id_karyawan')
                    ->orderBy('tb_absensi.tanggal_absensi', 'DESC')
                    ->findAll();
    }
}