Hi folks,
I have the following tables:
-
event
-
event_user
-
group
-
group_user
-
user
It’s a little untraditional in that Groups are invited to Events rather than inviting specific users. Thus, each User MANY_MANY Groups and each Group HAS MANY Events. For example, a user could belong to 3 groups, each group has 4 of their own events, so the user should be able to see those 12 events.
Currently, to see the events available to the current user, I use a for loop.
$mygroups = Yii::app()->user->model->groups; //Get's the current user's model, and then their groups
$mygroupsevents = array();
foreach($mygroups as $group) {
$mygroupsevents = array_merge($mygroupsevents, $group->events);
}
$this->render('events', array(
'events'=>$mygroupsevents,
));
However, I would rather load this data via a CActiveDataProvider so that I can feed it into the various widgets. Does anyone have a more graceful solution for me?
Thanks!