thanks for your reply @Steven. Below is the code (please set the pre tag to 1400px to get a better alignment):
<?php
public function listAction(){
$systemUser_loggedIn_authority = $this->systemUserLibrary->systemUser_loggedIn_authority_get();
$model_find_columns = $this->_list_model_find_columns_get($systemUser_loggedIn_authority);
$data = $this->_list_data_get(array('model_find_columns'=>$model_find_columns));
$this->view->setVar('customersOrStaffs', $data);
$this->view->pick('customersOrStaffs/list');
}
private function _list_data_get($parameters){
$staffs = Staffs::find(array(
'conditions' => 'TRUE', // not ready
'columns' => $parameters['model_find_columns']['staffs']
));
if(!$staffs->count()){ return NULL; }
$data = array();
foreach($staffs as $index => $staff){
$data[] = array(
'role' => 'staff',
'staff' => $staff,
'systemUser' => $parameters['model_find_columns']['system_users']
? SystemUsers::findFirst(array(
'conditions' => 'id = '.$staff->id__system_users, // not ready
'columns' => $parameters['model_find_columns']['system_users']
))
: NULL,
'personalInfo' => PersonalInfos::findFirst(array(
'conditions' => 'id = '.$staff->id__personal_infos, // not ready
'columns' => $parameters['model_find_columns']['personal_infos']
))
);
}
return $data;
}
private function _list_model_find_columns_get($systemUser_loggedIn_authority){
switch($systemUser_loggedIn_authority){
case 2:
return array(
'staffs' => 'id__system_users, id__personal_infos, id__staffs___supervisor, is_assistant, note_for_customer',
'system_users' => 'authority',
'personal_infos' => 'first_name, last_name, image, note_for_staff'
);
case 3:
case 4:
return array(
'staffs' => 'id__system_users, id__personal_infos, id__staffs___supervisor, is_assistant, is_active, note_for_customer',
'system_users' => 'authority, username, language, create_date, last_update, is_active',
'personal_infos' => 'first_name, last_name, image, phone, email, address, last_update, note_for_staff'
);
default:
return array(
'staffs' => 'id__system_users, id__personal_infos, id__staffs___supervisor, is_assistant, note_for_customer',
'system_users' => NULL,
'personal_infos' => 'first_name, last_name, image'
);
}
}
/*
the staff row looks like this:
object(Phalcon\Mvc\Model\Row)#121 (6) {
["id__system_users"]=>
string(1) "1"
["id__personal_infos"]=>
string(1) "1"
["id__staffs___supervisor"]=>
NULL
["is_assistant"]=>
string(1) "0"
["is_active"]=>
string(1) "1"
["note_for_customer"]=>
NULL
}
and then if I isset($data[0]['staff']['note_for_customer']); I will get TRUE;
*/
What version of Phalcon (1.3.x or 2.0.0) are you using and do you have a code sample to show exactly how you found the issue so that we can try to replicate it?