1
I’m trying to load the model in Ibraries, but an error is appearing.
Follow the code below:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Menu
{
private $CI;
public function __construct()
{
$this->CI =& get_instance();
$this->CI->load->model('menu_model');
}
public function get_all_menu_modulos()
{
// $this->load->model('Menu_model');
// $id_group = $this->ion_auth->get_users_groups()->row()->id;
$id_group = 1;
return $this->menu_model->get_all_menu_id_group($id_group);
}
}
?>
My model:
<?php
defined('BASEPATH') OR exit('Ação não permitida');
class Menu_model extends CI_Model{
public function get_menu() {
$this->db->select([
'menu_modulos.*'
]);
return $this->db->get('menu_modulos')->result();
}
public function get_submenu() {
$this->db->select([
'menu_modulos.*',
'menu_modulo_servicos.*'
]);
$this->db->join('menu_modulos','menu_modulo_id=menu_modulo_servico_id_menu_modulo','LEFT');
return $this->db->get('menu_modulo_servicos')->result();
}
public function get_all_menu_id_group(){
$this->db->select([
'menu_modulos.*',
'menu_modulo_servicos.*',
'permissoes.*'
]);
$this->db->join('menu_modulo_servicos','menu_modulo_servicos.menu_modulo_servico_id=permissoes.permissao_menu_servico','INNER');
$this->db->join('menu_modulos','menu_modulos.menu_modulo_id=menu_modulo_servicos.menu_modulo_servico_id_menu_modulo','INNER');
// $this->db->where('permissoes.permissao_id_group',$id_group);
return $this->db->get('permissoes')->result();
}
}
The following error appears:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Menu::$menu_model
Filename: libraries/Menu.php
Line Number: 22
Does anyone have any idea what it might be?
And your model exists?
– Woss
Added the model
– Victor Flores
If the class name is
Menu_model
, in theload
shouldn’t just beload("menu")
?– Woss
No...I’m trying to carry a model inside the Ibraries.
– Victor Flores