/**
  * Get filters
  *
  * @return Collection
  */
 public function getFilters()
 {
     $input = $this->collection->make($this->request->except($this->sortName));
     $filters = $this->collection->make();
     $input->filter(function ($value) {
         if ($this->ignoreEmptyFilters && is_string($value) && (string) $value == '') {
             return false;
         }
         return true;
     })->each(function ($value, $field) use($filters) {
         $filter = new Filter();
         $filter->setField($field);
         $filter->setValue($value);
         $filters->push($filter);
     });
     return $filters;
 }
 /** @test */
 public function it_applies_valid_filters_when_filters_configured()
 {
     $this->setMocks();
     $idFilter = new Filter('id', 2);
     $emailFilter = new Filter('email', ['*****@*****.**', '*****@*****.**']);
     $roleFilter = new Filter('role', 'admin');
     $statusFilter = new Filter('status', ['pending']);
     $otherFilter = new Filter('something', 'else');
     $this->parser->shouldReceive('getFilters')->once()->andReturn(collect([$idFilter, $roleFilter, $emailFilter, $otherFilter, $statusFilter]));
     $this->parser->shouldReceive('getSorts')->once();
     $filter = $this->createFilterMock('NotEmptyQueryFilter');
     $filter->shouldReceive('applyId')->with($idFilter->getValue());
     $filter->shouldReceive('applySimpleFilter')->once()->with($emailFilter)->passthru();
     $filter->shouldReceive('applySimpleFilter')->once()->with($roleFilter)->passthru();
     $filter->shouldReceive('applySimpleFilter')->once()->with($statusFilter)->passthru();
     $filter->shouldNotReceive('applySomething');
     $filter->shouldNotReceive('applySimpleFilter')->with($otherFilter);
     $this->query->shouldReceive('whereIn')->once()->with($emailFilter->getField(), $emailFilter->getValue());
     $this->query->shouldReceive('where')->once()->with($roleFilter->getField(), $roleFilter->getOperator(), $roleFilter->getValue());
     $this->query->shouldReceive('where')->once()->with($statusFilter->getField(), $statusFilter->getOperator(), $statusFilter->getValue()[0]);
     $filter->shouldReceive('applyDefaultFilters')->once()->withNoArgs()->passthru();
     $filter->applyFilters($this->query);
     $this->assertEquals(collect(['id', 'role', 'email', 'status']), $filter->getAppliedFilters());
 }