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

namespace App\Models;
use CodeIgniter\Model;

class PostsModel extends Model
{
    protected $table = 'department_posts';
    protected $primaryKey = 'id';

    protected $allowedFields = [
        'id', 'department_id', 'type', 'heading', 'description', 'image', 'created_at','created_by','row_status'
    ];

    public function getPostsWithDepartment()
    {
        return $this->db->table('department_posts')
            ->select('department_posts.*, department.department_name')
            ->join('department', 'department.id = department_posts.department_id', 'left') 
            ->where('department_posts.row_status', 1)
            ->get()
            ->getResultArray();
    }
}

?>