public function index(IndexOptions $opts)
{
$builder = $this->where($opts);
return $this->constructFilterOpts($builder, $opts, ['agent' => function ($value, $builder, IndexOptions $opts) {
return $this->matchAgent($value, $builder, $opts);
}, 'activity' => function ($value, $builder, IndexOptions $opts) {
return $this->matchActivity($value, $builder, $opts);
}, 'verb' => function ($value, $builder, IndexOptions $opts) {
return $this->addWhere($builder, 'verb.id', $value);
}, 'registration' => function ($value, $builder, IndexOptions $opts) {
return $this->addWhere($builder, 'context.registration', $value);
}, 'since' => function ($value, $builder, IndexOptions $opts) {
$key = 'stored';
$op = '>';
return $builder->where(function ($query) use($key, $value, $op) {
$date = new Carbon($value);
$mongodate = new MongoDate($date->timestamp, $date->micro);
return $query->orWhere($key, $op, $mongodate)->orWhere('refs.' . $key, $op, $mongodate);
});
}, 'until' => function ($value, $builder, IndexOptions $opts) {
$key = 'stored';
$op = '<=';
return $builder->where(function ($query) use($key, $value, $op) {
$date = new Carbon($value);
$mongodate = new MongoDate($date->timestamp, $date->micro);
return $query->orWhere($key, $op, $mongodate)->orWhere('refs.' . $key, $op, $mongodate);
});
}, 'active' => function ($value, $builder, IndexOptions $opts) {
return $builder->where('active', $value);
}, 'voided' => function ($value, $builder, IndexOptions $opts) {
return $builder->where('voided', $value);
}]);
}