Filter by date range
@param  Filter\FilterDateRange $filter
@return void
430697
public function applyFilterDateRange(Filter\FilterDateRange $filter)
	{
		$conditions = $filter->getCondition();

		$value_from = $conditions[$filter->getColumn()]['from'];
		$value_to = $conditions[$filter->getColumn()]['to'];

		if ($value_from) {
			try {
				$date_from = DateTimeHelper::tryConvertToDateTime($value_from, [$filter->getPhpFormat()]);
				$date_from->setTime(0, 0, 0);

				$this->data_source->where('DATE(%n) >= ?', $filter->getColumn(), $date_from);
			} catch (DataGridDateTimeHelperException $ex) {
				// ignore the invalid filter value
			}
		}

		if ($value_to) {
			try {
				$date_to = DateTimeHelper::tryConvertToDateTime($value_to, [$filter->getPhpFormat()]);
				$date_to->setTime(23, 59, 59);

				$this->data_source->where('DATE(%n) <= ?', $filter->getColumn(), $date_to);
			} catch (DataGridDateTimeHelperException $ex) {
				// ignore the invalid filter value
			}
		}
	}
803505
public function max($max = null, $addFilter = true, $forceInt = false)
    {
        if ($addFilter) {
            $this->addFilter(new RangeFilter(null, $max, $forceInt));
        }

        return $this->attr('max', $max);
    }
367995
public function applyFilterText(Filter\FilterText $filter)
	{
		$exprs = [];

		foreach ($filter->getCondition() as $column => $value) {
			if ($filter->isExactSearch()) {
				$exprs[] = Criteria::expr()->eq($column, $value);
				continue;
			}

			if ($filter->hasSplitWordsSearch() === false) {
				$words = [$value];
			} else {
				$words = explode(' ', $value);
			}

			foreach ($words as $word) {
				$exprs[] = Criteria::expr()->contains($column, $word);
			}
		}

		$expr = call_user_func_array([Criteria::expr(), 'orX'], $exprs);
		$this->criteria->andWhere($expr);
	}
968585
public function applyFilterDate(Filter\FilterDate $filter)
	{
		foreach ($filter->getCondition() as $column => $value) {
			try {
				$date = DateTimeHelper::tryConvertToDateTime($value, [$filter->getPhpFormat()]);

				$from = Criteria::expr()->gte($filter->getColumn(), $date->format('Y-m-d 00:00:00'));
				$to = Criteria::expr()->lte($filter->getColumn(), $date->format('Y-m-d 23:59:59'));

				$this->criteria->andWhere($from)->andWhere($to);
			} catch (DataGridDateTimeHelperException $ex) {
				// ignore the invalid filter value
			}
		}
	}
859546
public function applyFilterSelect(Filter\FilterSelect $filter)
	{
		$this->data_source = $this->data_source->findBy([$this->prepareColumn($filter->getColumn()) => $filter->getValue()]);
	}
854024
private function addExpiration(
        &$filters = [],
        \DateTime $dateSend = null
    ) {
        if ($filters) {
            $expiration = $dateSend ? $dateSend : new \DateTime();
            $expiration = $expiration->getTimestamp();
            foreach ($filters as &$filter) {
                $filter['exclusive_expire_date'] = $expiration;
            }
        }
    }
1058131
public function filter($filter)
    {
        preg_match_all("/(#\w+)/", $filter, $entityNames);
        preg_match_all("/(:\w+)/", $filter, $positions);

        $entityName = is_array($entityNames[0]) && isset($entityNames[0][0]) ? ltrim($entityNames[0][0], '#') : null;
        $position   = is_array($positions[0]) && isset($positions[0][0]) ? $positions[0][0] : null;

        $i = 0;

        $filtered = [];

        foreach ($this->entities as $name => $entity) {
            if ($i === 0 && ($entityName === $name || $entityName === null) && ($position === ':first' || $position === ':highest' || $position === null)) {
                $filtered[] = $entity;
            }

            if ($position === ':any' && ($entityName === $name || $entityName === null)) {
                $filtered[] = $entity;
            }

            if ($i + 1 === $this->entities->count() && ($entityName === $name || $entityName === null) && ($position === ':last' || $position === ':lowest')) {
                $filtered[] = $entity;
            }

            $i++;
        }

        $this->filtered = $filtered;

        return $this;
    }
731620
public function withFilter($filter) {
        if (!in_array($filter, [self::ALL, self::ANY, self::SOME, self::EXISTS, self::NOT_EXISTS, self::IN, self::NOT_IN], true)) {
            throw new InvalidArgumentException('Invalid filter type for sub-query');
        }

        $this->_filter = $filter;

        return $this;
    }
1233216
public function where($filter, $value = null)
    {
        foreach ($this->queries as $query) {
            $query->where($filter, $value);
        }

        return $this;
    }
148423
public function setFilter(FilterQuery $filter)
    {
        $this->result = array_merge($this->result, $filter->toArray()['bool']);

        return $this;
    }
565324
protected function filterLimitOffset(&$filter, $select)
    {
        $limit = null;
        $offset = null;

        if (array_key_exists('limit', $filter)) {
            $limit = (int) $filter['limit'];
            unset($filter['limit']);
        }
        if (array_key_exists('offset', $filter)) {
            $offset = (int) $filter['offset'];
            unset($filter['offset']);
        }
        $select->limit($limit, $offset);
    }
4939
public function gap(DateRange $range)
	{
		return self::cast($this->range->gap($range->range));
	}
167369
public function range($min, $max, $addFilter = true, $forceInt = false)
    {
        if ($addFilter) {
            $this->addFilter(new RangeFilter($min, $max, $forceInt));
        }

        $this->min($min, false)
            ->max($max, false);

        return $this;
    }
97314
public function addFilter(Filter $filter)
    {
        $key = $filter->getKey();
        $this->filters[$key] = $filter;
    }
1119939
public function setFilter($filter)
    {
        parent::setFilter($filter);

        $minValue = $this->getOption('min_value');
        $maxValue = $this->getOption('max_value');

        $this->userOptions['min_value'] = $minValue ? str_replace(',', '', $minValue) : $minValue;
        $this->userOptions['max_value'] = $maxValue ? str_replace(',', '', $maxValue) : $maxValue;
    }
857377
protected function filter(array $filter)
    {
        // email
        if(array_key_exists('authEmail', $filter) && strlen($filter['authEmail']) > 0) {
            $this->select->where->like('auth.auth_email', $filter['authEmail'] . '%');
        }
        
        //auth id
        if(array_key_exists('authId', $filter) && $filter['authId'] > 0) {
            $this->select->where(array(
                'history.auth_id = ?' => $filter['authId']
            ));
        }
        
        return $this;
    }
26547
public function filter( $filter, $params )
    {
        $argList = func_get_args( );

        array_shift( $argList );

        if ( isset( $this->filters[ $filter ] ) )
        {
            foreach( $this->filters[ $filter ] as $callback )
            {
                $argList[ 0 ] = call_user_func_array( $callback[ 'callback' ], $argList );

                if ( $this->debug )
                {
                    echo PHP_EOL . '->FILTER: ' . $filter . ' -> '
                            . $this->_serializeCallback( $callback[ 'callback' ] )
                            . ' + Priority: ' . $callback[ 'priority' ]
                            . PHP_EOL;
                }
            }
        }

        return $argList[ 0 ];
    }