-1

This is the error:

Severity: Notice Message: Undefined property: Products::$product_model Filename: controllers/Products.php Line Number: 29

This is my Controller code:

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

class Products extends CI_Controller {

    function __construct()
    {
        parent::__construct();
        if(!$this->session_data()):
            redirect(base_url());
        endif;
        $this->load->model('User_model');
        $this->load->model('Admin_model');
        $this->load->model('product_model','products');
    }

    function session_data()
    {
        return $this->session->userdata('ADMIN_SESSION');
    }


  function show($page,$data = array(),$str = '')
    {
        $userdata = $this->session_data();
        $data['setting'] = $str;
        $data['admin'] = $this->Admin_model->get_id($userdata['empcom_id']);
        $data['cat'] = $this->product_model->get_cat(); 
        $this->load->view($page,$data);
    }
    function index()
    {


        $this->show('template/header');
        $this->show('admin/admin_menus');

        $this->show('product_view');
          $this->show('template/footer');
    }
Devid Farinelli
  • 7,514
  • 9
  • 42
  • 73

1 Answers1

0

If you would like your model assigned to a different object name you can specify it via the second parameter of the loading method:

$this->load->model('model_name', 'foobar');
$this->foobar->method();

refernce : https://www.codeigniter.com/userguide3/general/models.html#loading-a-model

in your method you have assigned a different name for your product_model

$this->load->model('product_model','products');

$data['cat'] = $this->product_model->get_cat();

change that to

$data['cat'] = $this->products->get_cat();

Arun pandian M
  • 862
  • 10
  • 17