Я получаю неопределенную ошибку свойства в моей модели. Я использую спичечную библиотеку для модульного разделения. моя модель mproduct:
class MProducts extends Model{
/* function MProducts(){
$this->load->module_model('cities','MCities');
}*/
public $home_city_id ='';
function __construct(){
parent::Model();
$this->home_city_id = $this->MCities->getHomeCityId();
}
}
и я получаю эту ошибку:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: MProducts::$MCities
Filename: models/mproducts.php
Line Number: 12
моя модель mcities:
class MCities extends Model{
function MCities(){
parent::Model();
}
function getHomeCityId(){
$city = get_cookie('home_city');
$this->db->select('id');
$this->db->where('name', $city);
$Q = $this->db->get('omc_cities');
if($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
return $row['id'];
}
}
}
}
Я не знаю, что путь неправильный.
изм
мой контроллер продукта выглядит так:
class Admin extends Shop_Admin_Controller {
function Admin(){
parent::Shop_Admin_Controller();
// Check for access permission
check('Products');
// load modules/categories/model/mcats
$this->load->module_model('categories','MCats');
// load the MProducts model
$this->load->model('MProducts');
// load modules/cities/model/mcities
$this->load->module_model('cities','MCities');
// Set breadcrumb
$this->bep_site->set_crumb($this->lang->line('backendpro_products'),'products/admin');
}
function index(){
// Setting variables
$data['title'] = "Manage Products";
$data['products'] = $this->MProducts->getAllProducts();
$data['cities'] = $this->MCities->getCitiesDropDown();
$data['categories'] = $this->MCats->getCategoriesDropDown();
// we are pulling a header word from language file
$data['header'] = $this->lang->line('backendpro_access_control');
$data['page'] = $this->config->item('backendpro_template_admin') . "admin_product_home";
$data['module'] = 'products';
$this->load->view($this->_container,$data);
}
}