<?php

namespace App\Models;

use CodeIgniter\Model;

class DepartmentModel extends Model
{
    protected $table = 'm_department'; // Table name
    protected $primaryKey = 'department_id'; // Primary key

    // Fields that can be mass assigned
    protected $allowedFields = [
        'code','name','description','org_id','head_user_id','created_on','created_by','updated_on','updated_by','is_active',
    ];

    // Specify the return type of the results
    protected $returnType = 'array';

    // Enable timestamps (if you wish to handle created_at and updated_at automatically)
    protected $useTimestamps = false; // Set true if using CI4 timestamp features

   
    // Custom method example (e.g., fetching active departments)
    public function getActiveDepartments()
    {
        return $this->where('is_active', 1)->findAll();
    }
}
