public function processField2Filter(Builder $builder, Constraint $constraint)
 {
     if ($constraint->getOperator() == Constraint::OPERATOR_IN && is_array($constraint->getValue()) && $constraint->getValue()) {
         $builder->where('field2', $constraint->getValue()[0]);
         return true;
     }
 }
 public function testValue()
 {
     $this->specify("value is recognized correctly", function () {
         $this->assertEquals('abc', Constraint::make('abc')->getValue());
         $this->assertEquals('abc', Constraint::make('(ge)abc')->getValue());
         $this->assertEquals('abc', Constraint::make('!abc')->getValue());
         $this->assertEquals('abc', Constraint::make('!(ge)abc')->getValue());
         $this->assertEquals(['ab', 'bc'], Constraint::make('ab,bc')->getValue());
         $this->assertEquals(['ab', 'bc'], Constraint::make('!ab,bc')->getValue());
         $this->assertEquals('ab,bc', Constraint::make('(gt)ab,bc')->getValue());
         $this->assertEquals('%ab,bc%', Constraint::make('%ab,bc%')->getValue());
         $this->assertEquals('%ab,bc', Constraint::make('%ab,bc')->getValue());
         $this->assertEquals('ab,bc%', Constraint::make('ab,bc%')->getValue());
         $this->assertEquals('ab,bc', Constraint::make('!(gt)ab,bc')->getValue());
         $this->assertEquals('%ab,bc%', Constraint::make('!%ab,bc%')->getValue());
         $this->assertEquals('%ab,bc', Constraint::make('!%ab,bc')->getValue());
         $this->assertEquals('ab,bc%', Constraint::make('!ab,bc%')->getValue());
     });
 }
Beispiel #3
0
 /**
  * Build Constraint objects from given filter values
  *
  * @param string []|string
  *
  * @return Constraint[]|Constraint
  */
 protected function buildConstraints($values)
 {
     if (is_array($values)) {
         $constraints = [];
         foreach ($values as $value) {
             $constraints[] = Constraint::make($value);
         }
         return $constraints;
     } else {
         return Constraint::make($values);
     }
 }
 public function processRelationA_FieldFilter(Builder $builder, Constraint $constraint)
 {
     $builder->where('relation_a_field', $constraint->getValue());
     return true;
 }