Пример #1
0
 /**
  * Find a record by an attribute
  *
  * @param string $attribute
  * @param mixed  $value
  * @param array  $columns
  * @return \Jenssegers\Mongodb\Model
  */
 public function findBy($attribute, $value, $columns = ['*'])
 {
     $this->applyCriteria();
     return $this->builder->where($attribute, '=', $value)->first($columns);
 }
 /**
  * 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);
     });
 }