Code Igniter:Navigation(View) to Model:Severity: Notice Message: Undefined property:

Clash Royale CLAN TAG#URR8PPP
Code Igniter:Navigation(View) to Model:Severity: Notice Message: Undefined property:
UPDATE:
$ci =&get_instance();
$ci->load->model(your model);
$ci->(your model)->(your function);
Note: You have to call your model in your controller.Its working fine
Using above answer from (access model from view in codeigniter?)
My above code should work. But why it does not.
I am loading my menu in navigation using database. Im connecting directly from my model. In my navigation I have
$CI =& get_instance();
$CI->load->model('masterdata/MasterDataRole_','masterdatarole');
$menu = $CI->masterdatarole->loadMenu();
In my masterdata/MasterDataRole_ I have
masterdata/MasterDataRole_
<?php
class MasterDataRole_ extends CI_Model
//menu
//submenu
//screen
//check access rights
public function hasAccess($page_id,$level)
$query = $this->db->select('RoleAccess')
->from('masterdatarolemapping')
->where('ItemLevel',$level)
->where('ItemSysID',$page_id)
->where('MasterDataRoleID',$this->session->userdata('UserID'))
->get();
if($query)
if($query->num_rows() > 0)
$data = $query->row();
return $data->access;
But I get error saying
A PHP Error was encountered
Severity: Notice
Message: Undefined property: MasterDataRole::$menu
Filename: templates/navigation.php
Line Number: 117
In my Navigation I have:
<?php foreach ($menu as $m): echo $m;?>
<?php if($CI->menu->hasAccess($m->SysID,'menu') == 'yes'): ?>
<?php endif; ?>
<?php endforeach; ?>
Any Idea is appreciated.
UPDATE
UPDATE
error is on this <?php if($CI->menu->hasAccess($m->SysID,'menu') == 'yes'): ?>
<?php if($CI->menu->hasAccess($m->SysID,'menu') == 'yes'): ?>
this line <?php foreach ($menu as $m): echo $m;?> give the list of menu
<?php foreach ($menu as $m): echo $m;?>
1 Answer
1
$CI->load->model('masterdata/MasterDataRole_','masterdatarole');
$menu = $CI->masterdatarole->loadMenu();
Should be masterdatarole not menu
masterdatarole
menu
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.