Applies filter condition for the table column.

@param \Freshbitsweb\Laratables\QueryHandler Query object
@param string Column name
@param string Search string

@return \Freshbitsweb\Laratables\QueryHandler Query object
333691
protected static function applyFilter($query, $column, $searchValue)
    {
        if ($methodName = self::hasCustomSearch($column)) {
            return self::$class::$methodName($query, $searchValue);
        }

        if (isRelationColumn($column)) {
            return self::applyRelationFilter($query, $column, $searchValue);
        }

        $searchValue = '%'.$searchValue.'%';

        return $query->orWhere($column, 'like', "$searchValue");
    }
1300702
public function filtering()
    {
        if ($this->request->hasHeader('search-protection')) {
            $this->request->setSearchableColumnIndex($this->columns, $this->columnDef['filter']);
        }
        $columns          = $this->request['columns'];
        $this->collection = $this->collection->filter(function ($row) use ($columns) {
            $data                  = $this->serialize($row);
            $this->isFilterApplied = true;
            $found                 = [];

            $keyword = $this->request->keyword();
            foreach ($this->request->searchableColumnIndex() as $index) {
                $column = $this->getColumnName($index);
                if (!$value  = Arr::get($data, $column)) {
                    continue;
                }

                if ($this->isCaseInsensitive()) {
                    $found[] = Str::contains(Str::lower($value), Str::lower($keyword));
                } else {
                    $found[] = Str::contains($value, $keyword);
                }
            }

            return in_array(true, $found);
        }
        );
    }
1111348
protected function applySearchToQuery($query, $columns, $boolean = 'and')
    {
        $term = $this->searchTerm;

        if ($scopeMethod = $this->searchScope) {
            $searchMethod = $boolean == 'and' ? 'where' : 'orWhere';
            $query->$searchMethod(function ($q) use ($term, $columns, $scopeMethod) {
                $q->$scopeMethod($term, $columns);
            });
        }
        else {
            $searchMethod = $boolean == 'and' ? 'searchWhere' : 'orSearchWhere';
            $query->$searchMethod($term, $columns, $this->searchMode);
        }
    }
225539
public function filtering()
    {
        $this->query->where(
                function ($query) {
            $globalKeyword = $this->setupKeyword($this->request->keyword());
            $queryBuilder  = $this->getQueryBuilder($query);
            if ($this->request->hasHeader('search-protection')) {
                $this->request->setSearchableColumnIndex($this->columns, $this->columnDef['filter']);
            }

            foreach ($this->request->searchableColumnIndex() as $index) {
                $columnName = $this->getColumnName($index);
                if ($this->isBlacklisted($columnName)) {
                    continue;
                }

                // check if custom column filtering is applied
                if (isset($this->columnDef['filter'][$columnName])) {
                    $columnDef         = $this->columnDef['filter'][$columnName];
                    // check if global search should be applied for the specific column
                    $applyGlobalSearch = count($columnDef['parameters']) == 0 || end($columnDef['parameters']) !== false;
                    if (!$applyGlobalSearch) {
                        continue;
                    }

                    if ($columnDef['method'] instanceof Closure) {
                        $whereQuery = $queryBuilder->newQuery();
                        call_user_func_array($columnDef['method'], [$whereQuery, $this->request->keyword()]);
                        $queryBuilder->addNestedWhereQuery($whereQuery, 'or');
                    } else {
                        $this->compileColumnQuery(
                                $queryBuilder, Helper::getOrMethod($columnDef['method']), $columnDef['parameters'], $columnName, $this->request->keyword()
                        );
                    }
                } else {
                    if (count(explode('.', $columnName)) > 1) {
                        $eagerLoads     = $this->getEagerLoads();
                        $parts          = explode('.', $columnName);
                        $relationColumn = array_pop($parts);
                        $relation       = implode('.', $parts);
                        if (in_array($relation, $eagerLoads)) {
                            $this->compileRelationSearch(
                                    $queryBuilder, $relation, $relationColumn, $globalKeyword
                            );
                        } else {
                            $this->compileGlobalSearch($queryBuilder, $columnName, $globalKeyword);
                        }
                    } else {
                        $this->compileGlobalSearch($queryBuilder, $columnName, $globalKeyword);
                    }
                }

                $this->isFilterApplied = true;
            }
        }
        );
    }
861005
public function count($name, $query, CountableFilterInterface $filter)
    {
        // if the columnname is not set, assume an id field based on a table name
        $columnName  = (empty($this->columnName))
                            ?   $name
                            :   $this->columnName;

        if ( ! $this->includeEmpty) {
            $query->whereNotNull($columnName);
        }

        return $query->select(
                        "{$columnName} AS {$this->columnAlias}",
                        DB::raw("{$this->countRaw} AS {$this->countAlias}")
                     )
                     ->groupBy($columnName)
                     ->pluck($this->countAlias, $this->columnAlias);
    }
329254
@SuppressWarnings("unchecked")
    public void filterTable(String search) {

        m_container.removeAllContainerFilters();
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(search)) {
            m_container.addContainerFilter(
                new Or(
                    new SimpleStringFilter(TableColumn.Channel, search, true, false),
                    new SimpleStringFilter(TableColumn.ParentChannel, search, true, false),
                    new SimpleStringFilter(TableColumn.File, search, true, false)));
        }
        if ((getValue() != null) & !((Set<Logger>)getValue()).isEmpty()) {
            setCurrentPageFirstItemId(((Set<Logger>)getValue()).iterator().next());
        }
    }
596085
public function scopeSearchFilter($query, $q)
    {
        if(!empty($q)){
            return $query->where(DB::raw('LOWER(name)'), 'LIKE', '%' . strtolower($q) . '%');
        }
    }
888310
public function scopeFilter($query)
    {
        if (!$this->filters) {

            $message = 'Please set the $filters property.';
            throw new FilterableSortableException($message);
        }

        $this->filters = app()->make($this->filters);

        if (!$this->filters instanceof QueryFilters) {

            $message = '$filters property must be a class instance of QueryFilter.';
            throw new FilterableSortableException($message);
        }

        return $this->filters->apply($query);
    }
652457
public function search( $query ) {
		$marshaler = new Marshaler();

		$args = [
			'TableName' => 'wpsnapshots-' . $this->repository,
		];

		if ( '*' !== $query ) {
			$args['ConditionalOperator'] = 'OR';

			$args['ScanFilter'] = [
				'project' => [
					'AttributeValueList' => [
						[ 'S' => strtolower( $query ) ],
					],
					'ComparisonOperator' => 'CONTAINS',
				],
				'id'      => [
					'AttributeValueList' => [
						[ 'S' => strtolower( $query ) ],
					],
					'ComparisonOperator' => 'EQ',
				],
			];
		}

		try {
			$search_scan = $this->client->getIterator( 'Scan', $args );
		} catch ( \Exception $e ) {
			Log::instance()->write( 'Error Message: ' . $e->getMessage(), 1, 'error' );
			Log::instance()->write( 'AWS Request ID: ' . $e->getAwsRequestId(), 1, 'error' );
			Log::instance()->write( 'AWS Error Type: ' . $e->getAwsErrorType(), 1, 'error' );
			Log::instance()->write( 'AWS Error Code: ' . $e->getAwsErrorCode(), 1, 'error' );

			return false;
		}

		$instances = [];

		foreach ( $search_scan as $item ) {
			$instances[] = $marshaler->unmarshalItem( $item );
		}

		return $instances;
	}
141195
protected function applyFilters(\SelectQueryInterface $select, Query $query)
    {
        foreach ($this->fields as $name => $description) {
            if ($query->has($name)) {
                $select->condition($description['column'], $query->get($name));
            }
        }
    }
858889
public function queryFromFilter(Query $query, array $data = [])
    {
        $query = parent::queryFromFilter($query, $data);

        //"Name" field
        if (!empty($data['name']) && strlen($data['name']) > 2) {
            $query->where([sprintf('%s.tag LIKE', $this->getAlias()) => sprintf('%%%s%%', $data['name'])]);
        }

        return $query;
    }
974813
public function withQuery($query)
    {
        if (!is_string($query) && !method_exists($query, '__toString')) {
            throw new \InvalidArgumentException('Query string must be a string');
        }
        $query = (string) $query;
        if (strpos($query, '?') === 0) {
            $query = substr($query, 1);
        }
        $query = $this->filterQueryAndFragment($query);

        $new = clone $this;
        $new->query = $query;

        return $new;
    }
600373
public function search($query)
    {
        $this->validate($query);
        $client = $this->client->getClient();
        $result = array();
        // Change the match column name with the column name you want to search in it.
        $params = [
                'index' => $this->client->getIndex(),
                'type'  => $this->client->getType(),
                'body'  => [
                    'query' => [
                        'match' => [ $this->searchColumn => $query],
                    ],
                ],
            ];
        $query  = $client->search($params);
            
        return  $this->extractResult($query);
    }
239394
public function filter()
    {
        $condition = func_get_args();
        $cName = Utility::get($condition, 0);
        if (gettype($cName)=="object" && is_callable($cName)) {
            //Able to filter by function
            return $this->filterByFunc($cName);
        }
        $operator = Utility::get($condition, 1);
        $value = Utility::get($condition, 2);
        $optional_value = Utility::get($condition, 3);

        if ($cName===null||$operator===null) {
            throw new \Exception('dataStore->filter() requires condition in array form ($colname,$operator,$value)');
        }

        $result = array();
        $cType = $this->metaData["columns"][$cName]["type"];
        $dtFormat = null;
        if (in_array($cType, array("datetime", "date", "time"))) {
            switch ($cType)
            {
            case "datetime":
                $dtFormat = Utility::get($this->metaData["columns"][$cName], "format", "Y-m-d H:i:s");
                break;
            case "date":
                $dtFormat = Utility::get($this->metaData["columns"][$cName], "format", "Y-m-d");
                break;
            case "time":
                $dtFormat = Utility::get($this->metaData["columns"][$cName], "format", "H:i:s");
                break;
            }
            $value =  \DateTime::createFromFormat($dtFormat, $value);
        }
        
        foreach ($this->rows as $row) {
            $columnValue = $row[$cName]; 
            if ($dtFormat!==null) {
                $columnValue =  \DateTime::createFromFormat($dtFormat, $columnValue);
            }
            switch($operator)
            {
            case "=":
            case "==":
            case "equal":
                if ($columnValue==$value) {
                    array_push($result, $row);
                }
                break;
            case "===":
                if ($columnValue===$value) {
                    array_push($result, $row);
                }
                break;
            case "!=":
            case "notEqual":
                if ($columnValue!=$value) {
                    array_push($result, $row);
                }
                break;
            case "!==":
                if ($columnValue!==$value) {
                    array_push($result, $row);
                }
                break;
            case ">":
            case "gt":
                if ($columnValue>$value) {
                    array_push($result, $row);
                }
                break;
            case ">=":
                if ($columnValue>=$value) {
                    array_push($result, $row);
                }
                break;
            case "<":
            case "lt":
                if ($columnValue<$value) {
                    array_push($result, $row);
                }
                break;
            case "<=":
                if ($columnValue<=$value) {
                    array_push($result, $row);
                }
                break;
            case "contain":
            case "contains":
                if (strpos(strtolower($columnValue), strtolower($value))!==false) {
                    array_push($result, $row);
                }
                break;
            case "notContain":
            case "notContains":
                if (strpos(strtolower($columnValue), strtolower($value))===false) {
                    array_push($result, $row);
                }
                break;
            case "between":
                if ($value<$columnValue && $columnValue<$optional_value) {
                    array_push($result, $row);
                }
                break;
            case "notBetween":
                if (!($value<$columnValue && $columnValue<$optional_value)) {
                    array_push($result, $row);
                }
                break;
            case "in":
                if (!is_array($value)) {
                    $value = array($value);
                }
                if (in_array($columnValue, $value)) {
                    array_push($result, $row);
                }
                break;
            case "notIn":
                if (!is_array($value)) {
                    $value = array($value);
                }
                if (!in_array($columnValue, $value)) {
                    array_push($result, $row);
                }
                break;
            case "startWith":
            case "startsWith":
                if (strpos(strtolower($columnValue), strtolower($value)) === 0) {
                    array_push($result, $row);
                }
                break;
            case "notStartWith":
            case "notStartsWith":
                if (strpos(strtolower($columnValue), strtolower($value)) !== 0) {
                    array_push($result, $row);
                }
                break;
            case "endWith":
            case "endsWith":
                if (strpos(strrev(strtolower($columnValue)), strrev(strtolower($value))) === 0) {
                    array_push($result, $row);
                }
                break;
            case "notEndWith":
            case "notEndsWith":
                if (strpos(strrev(strtolower($columnValue)), strrev(strtolower($value))) !== 0) {
                    array_push($result, $row);
                }
                break;
            default:
                throw new \Exception("Unknown operator [$operator]");
                return $this;
                break;
            }
        }
        return new DataStore($result, $this->metaData);
    }
823444
protected function _where($query)
    {
        $link = null;
        $type_check = true;

        if ($query instanceof AnConfig) {
            $type_check = false;
            $query = $query->query;
        }

        $description = $query->getRepository()->getDescription();
        $clauses = array();
        if ($description->getInheritanceColumn() && $type_check) {
            $resource = $description->getInheritanceColumn()->resource->getAlias();
            //the table type column name
            $type_column_name = $resource.'.'.$description->getInheritanceColumn()->name;

            $scopes = AnConfig::unbox($query->instance_of);
            if (empty($scopes)) {
                $scopes = array($description);
            } else {
                if (!is_array($scopes)) {
                    $scopes = array($scopes);
                }
            }

            foreach ($scopes as $index => $scope) {
                $inheritance_type = $this->_inheritanceTree($scope);
                if (!empty($inheritance_type) && $inheritance_type != '%') {
                    $operator = substr($inheritance_type, -1) == '%' ? 'LIKE' : '=';
                    $scopes[$index] = $type_column_name.' '.$operator.' \''.$inheritance_type.'\'';
                } else {
                    unset($scopes[$index]);
                }
            }
            if (!empty($scopes)) {
                $clauses[] = '('.implode(' OR ', $scopes).')';
            }
        }

        if (!empty($query->where)) {
            $clause = '';
            foreach ($query->where as $where) {
                $clause .= $this->_buildWhere($query, $where);
            }
            if (!empty($clause)) {
                $clauses[] = '('.$clause.')';
            }
        }

        foreach ($query->link as $link) {
            $clauses = array_merge($clauses, $this->_where($link));
        }

        return $clauses;
    }
63243
private function _hasFilterExecuteForCyrillicColumn(string $search, string $column): bool
    {
        if (!preg_match("/[\w]+/i", $search) && \Assurrussa\GridView\Enums\FilterEnum::hasFilterExecuteForCyrillicColumn($column)) {
            return true;
        }

        return false;
    }
608445
public function scopeSearch($query, $value)
    {
        if (!empty($value)) {
            return $query->where('name', 'like', '%' . $value . '%')
                ->orWhere('description', 'like', '%' . $value . '%');
        }

        return $query;
    }