Active Record Relations

Hi,

Assuming the data structure provided in the attachment image, I can add the "permissions" relation to the "Usergroups" class like this:




public function relations()

{

	return array(

		'usergroupsPermissions' => array(self::HAS_MANY, 'UsergroupsPermissions', 'groupid'),

		'permissions'           => array(self::HAS_MANY, 'Permissions', array('permissionid' => 'id'), 'through' => 'usergroupsPermissions'),

	);

}



Now, can I add the "permissions" relation to the "Users" class directly? If yes, how?

Alright, seems like adding the exact same code to the “Users” model will do the trick :D