$invited = Model_Invite::find() ->where('user_id', $this->current_user->id) ->related(array('invited_by', 'event')) ->get(); foreach ($invited as $i) $invites[] = $i->event_id;
if (count($invites) > 0) { $events = $this->data['events'] = Model_Event::find() ->where('start_date', '>=', date('Y-m-d')) ->where('id', 'IN', $invites) ->related(array('user', 'attendees')) ->order_by('start_date', 'asc') ->order_by('start_time', 'asc') ->get(); }
Users -> has_many <- UserEvents, UserEvents -> belongs_to Users Events -> has_many <- UserEvents, UserEvents -> belongs_to Events
It looks like you're new here. If you want to get involved, click one of these buttons!