<?php
// app/Models/DepartmentModel.php

namespace App\Models;
use CodeIgniter\Model;

class ResidentsModel extends Model
{
    protected $table = 'residents';
    protected $primaryKey = 'id';

    protected $allowedFields = [
        'id', 'department_id', 'name', 'position', 'registration_no', 'image', 'publication', 'services', 'created_at','created_by','row_status'
    ];

    public function getResidentsWithDepartment()
    {
        return $this->select('residents.*, department.department_name')
                    ->join('department', 'residents.department_id = department.id')
                    ->where('residents.row_status', 1)
                    ->findAll();
    }
}

?>