Hello all,
I have the following usecase as depicted in attachment
I can get all projects for an activity easily using the relation:
public function relations() {
return array(
'projectActivityLinks' => array(self::HAS_MANY, 'ProjectActivity', 'activity'),
'projectActivities' => array(self::HAS_MANY, 'Project', array('project' => 'id'), 'through' => 'projectActivityLinks',),
);
}
I want to replace the projectActivities with two relations: intProjectActivities and extProjectActivities, where a relation exists between Project and Project_Type, called relatedType (project_type belongs to project). The type can be one of two values, with name=‘internal’ or name=‘external’.
I’m trying something like this:
public function relations() {
return array(
'projectActivityLinks' => array(self::HAS_MANY, 'ProjectActivity', 'activity'),
'intProjectActivities' => array(self::HAS_MANY, 'Project', array('project' => 'id'), 'through' => 'projectActivityLinks','with'=>'relatedType', 'on' => "relatedType.name='internal'",),
);
}
Please help