My situation: I want to bring a HABTM and a hasOne relation working in the same model. unfortunatelly its not loading the groupleaders userinformation into the usergroups.
any help apreciated
I'm having a table layout like this:
users
id
username
user_usergroups
id
user_id
usergroup_id
usergroups
id
groupname
groupleader (value is user_id)
usergroups model
public $hasAndBelongsToMany = array(
'User' => array(
'className' => 'Users',
'foreignKey' => 'usergroup_id',
'associationForeignKey' => 'user_id'
)
);
public $hasOne = array(
'GroupLeader' => array( 'className' => 'User',
'foreignKey' => 'usergroup_groupleader' )
);
the following was missing in the controller
$this->Staffgroup->recursive = 1;