Filter empty field

@param string $field

@return Expression
190567
public function whereEmpty($field)
    {
        return $this->where(
            '$or',
            array(
                array($field => null),
                array($field => ''),
                array($field => array()),
                array($field => array('$exists' => false))
            )
        );
    }
1026490
public function getFilterByField(string $fieldName): ? Filter
    {
        $fieldPath = Item::getPathByField($fieldName);
        foreach ($this->getFilters() as $filter) {
            if ($fieldPath === $filter->getField()) {
                return $filter;
            }
        }

        return null;
    }
710586
public function selectFields($fields)
    {
        # By default just select an empty string
        $select = "''";

        # If an array of fields have been passed
        if (is_array($fields)) {

            # If we have some fields, then add them to the query, ensuring they are quoted appropriately
            if (count($fields) > 0) {
                $select = "";

                foreach ($fields as $field) {
                    if ($select) {
                        $select .= ", ";
                    }
                    $select .= $this->quoteField($field);
                }
            }

        # if the fields isn't an array
        } elseif (!is_bool($fields)) {
            # Otherwise assume it is a string of fields to select and add them to the query
            if (strlen($fields) > 0) {
                $select = $fields;
            }
        }

        return $select;
    }
699549
public function isNull($field)
    {
        if (!($field instanceof ExpressionInterface)) {
            $field = new IdentifierExpression($field);
        }

        return $this->add(new UnaryExpression('IS NULL', $field, UnaryExpression::POSTFIX));
    }
943367
public function hasField(string $field): bool
    {
        if ($this->fields === null) {
            return false;
        }

        return in_array($field, $this->fields);
    }
364502
public function readonly($field)
    {
        if (is_string($field)) {
            $field = explode(',', $field);
        }

        $this->readonly = $field;

        return $this;
    }
959518
public function removeField($field)
    {
        $this->checkValidLoader();

        if (in_array($field, $this->loaders[ $this->contextLoader ])) {
            array_splice(
                $this->loaders[ $this->contextLoader ],
                array_search($field, $this->loaders[ $this->contextLoader ])
            );
        }

        return $this;
    }
1026868
public function count($field='*')
    {
        $this->getQuery()->type('select')->remove('fields')->set('count', $field);
        
        $result = $this->query();
        
        if ($result) {// get first row's value
            $result = current($result[0]);
        } else {
            $result = 0;
        }
        
        return $result;
    }
1336323
public function excludeFields(array $fields)
    {
        foreach ($fields as $fieldName) {
            $this->field($fieldName)->expression(false);
        }

        return $this;
    }
1207105
protected static function cleanFields($fields)
    {
        $new = [];
        $fieldList = explode(',', $fields);
        foreach ($fieldList as $f) {
            if (static::ID_FIELD !== trim(strtolower($f))) {
                $new[] = $f;
            }
        }

        return implode(',', $new);
    }
639435
public function getField($field)
    {
        if (isset($this->allFields[$field])) {
            return $this->allFields[$field];
        }

        return null;
    }
968148
public function order($field) {
        $order = [];
        if (is_array($field)) {
            foreach ($field as $key => $value) {
                $order[] = $key . ' ' . $value;
            }
        } else {
            $order = func_get_args();
        }
        $order = implode(',', $order);
        $this->order = !empty($order) ? ' ORDER BY ' . $order : '';
        return $this;
    }
1304277
public function removeField($field)
    {
        $field = $this->resolveAlias($field);

        unset($this->fields[$field], $this->data[$field]);

        return $this;
    }
241436
public function getField($field)
    {
        return $this->getFields()->filter(function($input) use ($field) {
            return $field === $input->getName();
        })->first();
    }
1175278
protected function schema($field = null)
    {
        if ($field === null) {
            return $this->schema;
        } else {
            if (isset($this->schema[$field])) {
                return $this->schema[$field];
            } else {
                return false;
            }
        }
    }
256292
private function fieldWithCollation(string $field, string $collation): Expression
    {
        return DB::raw($field . ' /*! COLLATE ' . $collation . ' */');
    }
157694
public function filterLt(string $field, $value): self
    {
        $this->filters[] = new IndexQueryFilter($field, IndexQueryFilterOperator::LESS_THAN(), $value);
        return $this;
    }