Hi,
I am building a relationship between two models: stores and managers.
Managers can be at a store, district or regional level, and have a number relative to the store, district or region they manage.
Stores have a store number, a district number and a region number.
I am trying to write a relationship in the manager model like this:
public function relations() {
return array(
'stores' => array(self::HAS_MANY, 'Store', '<conditional key>'),
);
}
I need a control structure to tell if the stores should be queried by region, district or store number according to the manager’s role.
Is it possible to do in Yii? Or do I have to write a custom scope instead of a relationship?
Thank you,
gm