Hey,
i have a little strange Problem. When i try to load a model over the Autoload.php and try to use it, i'll become an Error that the model could not found (Undefined property: Home::$users_to_groups), but when i load it over $this->load->model() it works. But why?
Here is the Code that i Use:
PHP Code:
<?php
class Rights_management {
private $_ci = null;
private $_aGroupIds = [];
public function __construct() {
$this->_ci = get_instance();
//$this->_ci->load->model('rights/Users_to_groups_model', 'users_to_groups');
$this->_aGroupIds = $this->_getUserInformation();
}
private function _getUserInformation() {
$aAccountData = element('accountData', $this->_ci->session->userdata());
if(!empty($aAccountData)) {
$iUserId = element('id', $aAccountData);
return array_column($this->_ci->users_to_groups->getGroupIds($iUserId), 'group_id');
}
return [];
}
public function checkAccess($sCode) {
return $this->_ci->groups_to_rights->checkAccess($sCode, $this->_aGroupIds);
}
}
Has anywhone an Idea what i do wrong? When i insert the commented Line, than the script is full functionally (the groups_to_rights modal can be found).