<?php

namespace App\Controllers\Admin;

use App\Controllers\BaseController;
use App\Models\Common_model;

class MyAttendance extends BaseController
{
    protected $common;
    protected $table = 'attendance';

    public function __construct()
    {
        $this->common = new Common_model();
    }

    public function index()
    {
        if (session()->get('role') !== 'Employee') {
            return redirect()->to('/home')->with('error', 'Unauthorized');
        }

        $userId = session()->get('user_id');

        $data['records'] = $this->common->getData(
            $this->table,
            'attendance_date,punch_in_time,punch_out_time,work_mode',
            ['user_id' => $userId],
            [],
            'attendance_date DESC'
        );

        return view('admin/my_attendance', $data);
    }
}

