/** * Constructs a Mongo match using the given activity and options. * @param String $activity Activity to be matched. * @param IndexOptions $opts Index options. * @return Builder */ private function matchActivity($activity, Builder $builder, IndexOptions $opts) { return $builder->where(function ($query) use($activity, $builder, $opts) { $keys = ['object.id']; if ($opts->getOpt('related_activities') === true) { $keys = array_merge($keys, ['context.contextActivities.parent.id', 'context.contextActivities.grouping.id', 'context.contextActivities.category.id', 'context.contextActivities.other.id']); } $query = $this->addWheres($builder, $keys, $activity); }); }