I am trying to load model in my view file but problem is model is not loading and given error Message: Undefined property: CI_Loader::$CoupanCatModel
Following is my code
Controller
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class CoupanCategory extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('coupans/CoupanCatModel');
//$this->load->model('ForeignData_model');
}
public function init(){
$logoUrls = 'no-image.jpg';
$webUrls = 'no-image.jpg';
$mobileUrls = 'no-image.jpg';
$this->load->library('upload');
$config['upload_path'] = './assets/images/coupans/category/';
$config['allowed_types'] = 'gif|jpg|png';
$config['encrypt_name'] = TRUE;
$config['max_size'] = 20000;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this->upload->initialize($config);
if ( ! $this->upload->do_upload('ccImage')){
$error = array('error' => $this->upload->display_errors());
}
else{
$data = $this->upload->data();
$logoUrls = $data['file_name'];
}
$is_init = $this->CoupanCatModel->init($logoUrls);
if ($is_init) {
redirect(base_url().'rech/'.ACCESS_KEY.'/coupans/coupan_category?create=success&success=New coupan category create','refresh');
}
else
{
redirect(base_url().'rech/'.ACCESS_KEY.'/coupans/coupan_category?create=failed&error=something want wrong','refresh');
}
}
}
Model
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class CoupanCatModel extends CI_Model {
public function init($logoUrls)
{
new_id:
$sc_id = 'SC'.mt_rand(1000,9999);
if ($this->check_id($sc_id))
goto new_id;
$sc_title = (isset($_POST['coupan_cat_name']) && $_POST['coupan_cat_name'] != '') ? trim($_POST['coupan_cat_name']):'';
$sc_logo = $logoUrls;
// $sc_web_image = $webUrls;
//$sc_mobile_image = $mobileUrls;
$active_flag =1;
$this->db->set('oc_cat_id',$sc_id);
$this->db->set('oc_cate_name',$sc_title);
//$this->db->set('sc_description',$sc_description);
// $this->db->set('sc_logo',$sc_logo);
$this->db->set('oc_web_image',$sc_logo);
//$this->db->set('sc_mobile_image',$sc_mobile_image);
$this->db->set('active_flag',$active_flag);
$this->db->insert('tbl_oc_category');
return true;
}
public function get_data($oc_cat_id = false)
{
if ($oc_cat_id != false) {
$this->db->where('oc_cat_id', $sc_id);
$query = $this->db->get('tbl_oc_category');
return $query->row_array();
}
$query = $this->db->get('tbl_oc_category');
return $query->result_array();
}
}
View i just load model like
<?php
$this->load->model('coupans/CoupanCatModel');
$scData = $this->CoupanCatModel->get_data();
echo '<pre>ddsd';
print_r($records);
die();
?>
But problem is model is not loading and given error
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Loader::$CoupanCatModel
Filename: coupans/coupan_category.php
Line Number: 139