Check if field is sortable for given model.

@param Builder $builder query builder
@param string $field field name

@return bool
161803
protected function isFieldSortable(Builder $builder, $field)
    {
        $sortable = $this->_getSortableAttributes($builder);

        return in_array($field, $sortable) || in_array('*', $sortable);
    }
57964
protected function addDraft(Builder $builder): void
    {
        $builder->macro('draft', function (Builder $builder) {
            return $builder->update(['is_drafted' => 1]);
        });
    }
911424
protected function addUnordered(Builder $builder)
    {
        $builder->macro('unordered', function (Builder $builder) {

            $this->remove($builder, $builder->getModel());
            return $builder;
        });
    }
857196
public function apply(Builder $builder, Model $model)
    {
        $column = $model->getQualifiedPositionColumn();

        $builder->orderBy($column);

        $this->addUnordered($builder);
    }
117715
public function handleBuilder($builder, $value)
    {
        foreach ($value as $orderByClause) {
            $builder->orderBy(
                $orderByClause['field'],
                $orderByClause['order']
            );
        }

        return $builder;
    }
272648
public function apply(Builder $builder)
    {
        $this->builder = $builder;

        // We need to select all columns from the original
        // table, since many joins can mess up the selected fields
        $this->builder->select("{$this->getTableName()}.*");

        foreach ($this->filters() as $name => $value) {
            $this->callFilterMethod($name, $value);
        }

        return $this->builder;
    }
1057947
protected function addWithDrafts(Builder $builder)
    {
        $builder->macro('withDrafts', function (Builder $builder) {
            $this->remove($builder, $builder->getModel());

            return $builder;
        });
    }
921789
protected function isFilterAppliable(QueryBuilder $queryBuilder, string $field): bool
    {
        $qbClone = clone $queryBuilder;

        try {
            $qbClone->andWhere($field.' IS NULL');

            // Generating SQL throws a QueryException if using wrong field/association
            $qbClone->getQuery()->getSQL();
        } catch (QueryException $e) {
            return false;
        }

        return true;
    }
724708
public function setSort($sort, $field = null)
    {
        $param = $this->buildParam('facet.sort', $field);
        return $this->set($param, $sort);
    }
350916
public function apply(Builder $builder, Model $model) {
    $subclassTypes = array_keys($model->getSingleTableTypeMap());

    if (!empty($subclassTypes) ) {
      $builder->whereIn($model->getQualifiedSingleTableTypeColumn(), $subclassTypes);
    }
  }
114534
protected function applySorts(ModelQueryBuilder $builder): self
    {
        if ($this->hasSorts() === true) {
            $builder->addSorts($this->getSorts());
        }

        return $this;
    }
1214027
public function byFieldValue(
        string $field,
        string $order
    ): SortBy {
        $this->sortsBy[] = [
            'type' => self::TYPE_FIELD,
            'field' => Item::getPathByField($field),
            'order' => $order,
        ];

        return $this;
    }
909916
protected function getSelectedAttributes(Builder $builder)
    {
        $selected = $builder->getSelects();

        return array_merge($selected, [
            $builder->getSchema()->memberOf(),
        ]);
    }
146213
public function isSortable(array $item)
    {
        $config = Config::createField($item);

        return $config->getSortField() ? true : false;
    }
671446
public function isFieldHidden(Field $field)
    {
        if ($field->get('hide_when_prepopulated') == 'yes') {
            if (isset($_REQUEST['prepopulate'])) {
                foreach ($_REQUEST['prepopulate'] as $field_id => $value) {
                    if ($field_id == $field->get('id')) {
                        return true;
                    }
                }
            }
        }

        return false;
    }
451612
public function remove(Builder $builder, Model $model)
    {
        $query = $builder->getQuery();

        foreach ((array)$query->wheres as $key => $where)
        {
            if ($where['column'] === $model->getTypeKeyName())
            {
                unset($query->wheres[$key]);

                $query->wheres = array_values($query->wheres);
            }
        }
    }
1009246
protected function isFieldValueBeDerivableFromListParent($field)
    {
        if ( ! $this->hasActiveListParent()) {
            return false;
        }

        $listParentData = $this->getListParentDataForRelation($this->listParentRelation);

        if ( ! $listParentData) {
            return false;
        }

        return $field == $listParentData->field();
    }