@param \Illuminate\Database\Query\Builder $query
@param array                              $filter

@return \Illuminate\Database\Query\Builder
768225
protected function buildQueryByFilter($query, $filter)
    {
        $tableName = $this->getBlankModel()->getTable();

        $query = $this->queryOptions($query);

        if (count($this->querySearchTargets) > 0 && array_key_exists('query', $filter)) {
            $searchWord = Arr::get($filter, 'query');
            if (!empty($searchWord)) {
                $query = $query->where(function($q) use ($searchWord) {
                    foreach ($this->querySearchTargets as $index => $target) {
                        if ($index === 0) {
                            $q = $q->where($target, 'LIKE', '%'.$searchWord.'%');
                        } else {
                            $q = $q->orWhere($target, 'LIKE', '%'.$searchWord.'%');
                        }
                    }
                });
            }
            unset($filter['query']);
        }

        foreach ($filter as $column => $value) {
            if (is_array($value)) {
                $query = $query->whereIn($tableName.'.'.$column, $value);
            } else {
                $query = $query->where($tableName.'.'.$column, $value);
            }
        }

        return $query;
    }
1313633
public function search($query, array $filters = [], $path = '/search.json')
	{
		$filters['q'] = $query;
		$url = $this->getUrl() . $path . '?' . http_build_query($filters);

		$this->_response = new Response(['json' => $this->request($url)]);
		return $this;
	}
186939
public function getSql($filter = []): string
    {
        if ($filter) {
            $this->filter($filter);
        }
        $qb = clone $this->getQueryBuilder();

        return $qb->toSQL();
    }
770550
public function buildFilter(&$query)
    {
        $this->filterTimestamp($query, 'updated_at');

        $query->andFilterWhere([
            'id' => $this->id,
        ]);
        $query->andFilterWhere(['like', 'name',  $this->name])
              ->andFilterWhere(['like', 'url',   $this->url]);
    }
310950
public function scopeClients(Builder $query)
    {
        $query->with('roles')->whereNotNull('tbl_users.id')->whereHas('roles', function ($query) {
            $query->whereIn('tbl_roles.name', ['member', 'users', 'user']);
        });


        return $query;
    }
1352291
public function select(array $filter = [], array $options = [])
    {
        // Create query object from filter and option arrays
        $query = $this->getQuery($filter, $options);

        try {
            $cursor = $this->getInstance()->executeQuery(
                $this->getParam('database') . '.' . $this->getCollection(),
                $query
            );
            $response = $cursor->toArray();

        } catch (MongoException $e) {
            new Exception('Unable to execute query');
        }

        return $response ?? false;
    }
1175587
public function scopeSearch(Builder $query, array $search = [])
    {
        if (empty($search)) {
            return $query;
        }

        if (!array_intersect(array_keys($search), $this->searchable)) {
            return $query;
        }

        return $query->where($search);
    }
929709
protected function search(Builder $query, Request $request): Builder
    {
        $phrase = $request->input('q');

        if (!$phrase || strlen($phrase) < $this->minimumSearchInputLength) {
            return $query;
        }

        if ($this->translationModel()) {
            return $this->searchQueryTranslations($query, $phrase);
        }

        return $this->searchQuery($query, $phrase);
    }
3449
public function build(Repository $query)
    {
        $filters = collect($this->filters());
        $count = $filters->count();

        if ($count === 0) {
            return;
        }

        foreach ($filters as $key => $filter) {
            $filters[$key] = new $filter();
        }

        return view($this->template, [
            'filters' => $filters,
            'chunk'   => ceil($count / 4),
        ]);
    }
808358
public function scopeFilteredByType(Builder $query, $type = null)
    {
        $type = is_null($type) ? request('f', 'all') : $type;

        if (in_array($type, ['audio', 'document', 'image', 'video', 'embedded']))
        {
            $query->whereType($type);
        }

        return $query;
    }
1224438
public function runQueryFilter(\Illuminate\Database\Query\Builder &$query)
    {
        if ($filter = $this->getOption('query_filter')) {
            $filter($query);
        }
    }
148423
public function setFilter(FilterQuery $filter)
    {
        $this->result = array_merge($this->result, $filter->toArray()['bool']);

        return $this;
    }
500263
public function withFilters(array $filters = null)
    {
        if ($filters) {
            foreach ($filters as $filter) {
                switch ($filter['type']) {
                    case 'select':
                        $this->select($filter['fields']);
                        break;
                    case 'andWhere':
                        $this->andWhere($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'orWhere':
                        $this->orWhere($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'andHaving':
                        $this->andHaving($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'orHaving':
                        $this->orHaving($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'addGroupBy':
                        $this->addGroupBy($filter['field']);
                        break;
                    case 'addOrderBy':
                        $this->addOrderBy($filter['field'], $filter['order']);
                        break;
                    case 'fkAddOrderBy':
                        $this->fkAddOrderBy($filter['field'], $filter['fkField'], $filter['order']);
                        break;
                    case 'paginate':
                        if (isset($filter['page'])) {
                            $this->paginate($filter['limit'], $filter['page']);
                        } else {
                            $this->paginate($filter['limit']);
                        }
                        break;
                }
            }
        }

        return $this;
    }
714741
private static function determineFilterComparing(array $filter, QueryBuilder $queryBuilder)
    {
        if (!\in_array($filter['operation'], ['=', '>', '>=', '<', '<=', '<>'])) {
            return null;
        }

        return static::filterComparing($filter, $queryBuilder);
    }
223374
public static function create($filter = array())
    {
        if ($filter instanceof self) {
            return $filter;
        }

        if (is_int($filter)) {
            $filter = array('page' => $filter);
        }

        return new self($filter);
    }
1166503
private function filter(Builder $query): Builder
    {
        $filters = $this->entity->getFilters();

        foreach ($filters as $filter) {
            $query = $filter->filter($query);
        }

        return $query;
    }
730697
protected function addTransUnitFilters(TransUnitQuery $query, array $filters = null)
    {
        if (isset($filters['_search']) && $filters['_search']) {
            if (!empty($filters['domain'])) {
                $query->filterByDomain(sprintf('%%%s%%', $filters['domain']), Criteria::LIKE);
            }

            if (!empty($filters['key'])) {
                $query->filterByKey(sprintf('%%%s%%', $filters['key']), Criteria::LIKE);
            }
        }
    }