<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Course_subcategory extends CI_Controller 
{
    public function __construct() 
    {
        parent::__construct();
        $this->load->model('Course_subcategory_model');
    }
    
    public function listing()
    {
        $request = $this->input->get();
        $data = $this->Course_subcategory_model->listing($request);
        echo json_encode($this->Course_subcategory_model->build_datatables($request['draw'], $this->Course_subcategory_model->totalCount(), $this->Course_subcategory_model->filteredCount($request), $data), JSON_UNESCAPED_UNICODE);
    }
    
    public function getallcategories(){
        $this->load->model('Course_category_model');
        $data = $this->Course_category_model->all(['status'=>1]);
         echo json_encode(['success'=>true, 'data'=>$data, JSON_UNESCAPED_UNICODE]);
    }
    
    public function all()
    {
        $request = $this->input->get();
        $data = $this->Course_subcategory_model->all($request['course_category_id']);
        echo json_encode(['course_subcategory' => $data], JSON_UNESCAPED_UNICODE);
    }
    
    public function getallids(){
        $ids = $this->Course_subcategory_model->getAllIds();
        echo json_encode(['success'=>true, 'data'=>$ids, JSON_UNESCAPED_UNICODE]);
    }
}
