Check if field is searchable for given model.

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

@return bool
187141
protected function isFieldSearchable(Builder $builder, $field)
    {
        $searchable = $this->_getSearchableAttributes($builder);
        $notSearchable =  $this->_getNotSearchableAttributes($builder);

        $field = preg_replace('#^!#', '', $field);

        return !in_array($field, $notSearchable) && !in_array('*', $notSearchable) && (in_array($field, $searchable) || in_array('*', $searchable));
    }
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;
    }
44577
protected function performSearch(Builder $builder, array $options = [])
    {
        if ($builder->callback) {
            return call_user_func(
                $builder->callback,
                ElasticClient::getFacadeRoot(),
                $builder->query,
                $options
            );
        }

        $results = [];

        $this
            ->buildSearchQueryPayloadCollection($builder, $options)
            ->each(function ($payload) use (&$results) {
                $results = ElasticClient::search($payload);

                $results['_payload'] = $payload;

                if ($this->getTotalCount($results) > 0) {
                    return false;
                }
            });

        return $results;
    }
646229
public function hasMutator($field) {
        $method = sprintf('set%sAttribute', Inflector::camelCase($field));

        if (method_exists($this, $method)) {
            return $method;
        }

        return null;
    }
1077777
public function isValueChanged($field)
    {
        if (!$this->IsNullable($field)) {
            return false;
        }

        return isset($this->nullableChanged[$field]);
    }
257248
public function count(Builder $builder)
    {
        $count = 0;

        $this
            ->buildSearchQueryPayloadCollection($builder, ['highlight' => false])
            ->each(function ($payload) use (&$count) {
                $result = ElasticClient::count($payload);

                $count = $result['count'];

                if ($count > 0) {
                    return false;
                }
            });

        return $count;
    }
429153
public function getField($field)
    {
        return isset($this->data[$field])
            ? $this->data[$field]
            : $this->searchField($field);
    }
909916
protected function getSelectedAttributes(Builder $builder)
    {
        $selected = $builder->getSelects();

        return array_merge($selected, [
            $builder->getSchema()->memberOf(),
        ]);
    }
869827
public function remove(Builder $builder)
    {
        $column = $builder->getModel()->getQualifiedDeletedAtColumn();

        $query = $builder->getQuery();

        foreach ((array) $query->wheres as $key => $where) {
            if ($this->isSoftDeleteConstraint($where, $column)) {
                unset($query->wheres[$key]);

                $query->wheres = array_values($query->wheres);
            }
        }
    }
134183
protected function getStatusColumn(Builder $builder)
    {
        if ($builder->getQuery()->joins && count($builder->getQuery()->joins) > 0) {
            return $builder->getModel()->getQualifiedStatusColumn();
        } else {
            return $builder->getModel()->getStatusColumn();
        }
    }
260548
protected function isQueryBuilder($model): bool
    {
        return $model instanceof \Illuminate\Database\Query\Builder
                    || $model instanceof \Illuminate\Database\Eloquent\Builder;
    }
861989
protected function _isDisabledFieldCache()
    {
        $class = get_class($this);
        if (isset(self::$_blDisableFieldCaching[$class]) && self::$_blDisableFieldCaching[$class]) {
            return true;
        }

        return false;
    }
1059458
protected function isFillable(string $field): bool
    {
        if (static::FILLABLE === '*') {
            return true;
        }

        if (!empty(static::FILLABLE)) {
            return in_array($field, static::FILLABLE);
        }

        if (static::SECURED === '*') {
            return false;
        }

        return !in_array($field, static::SECURED);
    }
167905
private function getJqSearchField($field)
    {
        // jqSearchable is not initialized
        if (!isset($this->jqSearchable) || !is_array($this->jqSearchable)) {
            return $field;
        }

        return isset($this->jqSearchable[$field]) ? $this->jqSearchable[$field] : $field;
    }
592781
public function apply($builder)
    {
        $values = $this->getValues();
        if (empty($values)) {
            return $builder;
        }
        $builder->whereIn('type_id', $values);
    }
942274
public function filter(Builder $builder): Builder
    {
        if (is_null($this->parameters) || $this->request->filled($this->parameters)) {
            return $this->run($builder);
        }

        return $builder;
    }
154265
public function isRequired($field)
    {
        $parts = explode('.', $field);
        $entity = $this->entity($parts);

        $isNew = true;
        if ($entity instanceof EntityInterface) {
            $isNew = $entity->isNew();
        }

        $validator = $this->_getValidator($parts);
        $fieldName = array_pop($parts);
        if (!$validator->hasField($fieldName)) {
            return false;
        }
        if ($this->type($field) !== 'boolean') {
            return $validator->isEmptyAllowed($fieldName, $isNew) === false;
        }

        return false;
    }