<?php

namespace App\Controllers\Api;
use App\Controllers\BaseController;

// use App\Models\_teacher;
// use App\Models\_document;
// use App\Models\_person;

class Teachers extends BaseController
{
    #Constructor to set some default values at class load
    // public function __construct()
    // {
    //     // parent::__construct();
    //     $this->teacher = new _teacher();
    //     $this->document = new _document();
    //     $this->person = new _person();
    // }

    public function lists($type = null){

        $searchString = " 1=1 ";
        if(!empty($type) && $type == 'primary'){
            $searchString = "p.teacherQualCat ='primary' AND p.employmentCat ='Government' ";
        }elseif(!empty($type) && $type == 'secondary'){
            $searchString = "p.teacherQualCat ='secondary' AND p.employmentCat ='Government' ";
        }elseif(!empty($type) && $type == 'health'){
            $searchString = "d.grade LIKE '%health%' ";
        }

        $list = $this->query_reader->get_list('get_api_teacher_list', array('search_query'=>$searchString,  'order_by'=>" ORDER BY U.id DESC "));
        return $this->getResponse(
            [
                'message' => 'Teachers retrieved successfully',
                'teachers' => $list
            ]
        );
        

    }
}