Set a list of fields that will be included during object serialization.

@param  string[] $fields
@return $this
430069
public function &serialize(...$fields)
    {
        if (!empty($fields)) {
            $this->serialize = array_unique(array_merge($this->serialize, $fields));
        }

        return $this;
    }
504891
public function unsetField($fields)
    {
        $fields = (array)$fields;
        foreach ($fields as $field) {
            unset($this->data[$field]);
        }

        return $this;
    }
525960
public function addFields($fields)
    {
        foreach ($fields as $field) {
            if (is_array($field)) {
                $this->addField(...$field);
            } else {
                $this->addField($field);
            }
        }

        return $this;
    }
1139127
public function groupBy($fields)
    {
        $fields = is_array($fields) ? $fields : func_get_args();
        $this->groupBy = array_merge($this->groupBy, $fields);
        return $this;
    }
1188232
public function select($fields)
    {
        if (!is_array($fields)) {
            $fields = func_get_args();
        }

        $fields = $this->addTablePrefix($fields);
        $this->addStatement('selects', $fields);
        return $this;
    }
109505
protected function setHtmlType(array &$fields)
    {
        foreach ($fields as $field) {
            $field->htmlType = $this->getHtmlType($field->getEloquentDataMethod());
        }

        return $this;
    }
389278
public function addFields(array $fields)
    {
        foreach ($fields as $field) {
            if (!$field instanceof FieldDefinitionInterface) {
                continue;
            }

            $this->addField($field);
        }

        return $this;
    }
313133
public function prependSelect($fields = [])
    {
        if (!is_array($fields)) {
            $fields = [$fields];
        }

        $collection = collect($this->select);
        foreach ($fields as $key => $field) {
            $collection->prepend($field, is_string($key) ? $key : null);
        }

        $this->select = $collection->all();

        return $this;
    }
207834
public function addLockFields($fields)
    {
        $fields = explode(',', str_replace(' ', '', $fields));
        $this->lockedFields = array_merge($this->lockedFields, $fields);
        return $this;
    }
748998
public function setFields(array $fields)
    {
        $this->fields = $fields;
        $this->queryBuilder->select(implode(', ', $fields));
        return $this;
    }
1338608
public function addField(Field ...$fields)
    {
        collect($fields)->map(function ($field) {
            $this->group['fields']->put($field->key(), $field->get());
        });

        return $this;
    }
374566
public function setFieldValues(array $values)
    {
        foreach ($values as $name => $value) {
            $this->setFieldValue($name, $value);
        }
        return $this;
    }
658493
protected function addColumns($fields)
    {
        $schema = [];

        foreach($fields as $field)
        {
            $schema[] = $this->addColumn($field);
        }

        return $schema;
    }
589660
public function setFields($fields = [], bool $all = false)
    {
        if (!is_array($fields) && !$fields instanceof \Traversable) {
            return $this;
        }

        foreach ($fields as $name => $value) {
            if ($all || $this->isFillable($name)) {
                try {
                    $this->setField($name, $value, true);
                } catch (AccessExceptionInterface $e) {
                    //We are suppressing field setting exceptions
                }
            }
        }

        return $this;
    }
1336323
public function excludeFields(array $fields)
    {
        foreach ($fields as $fieldName) {
            $this->field($fieldName)->expression(false);
        }

        return $this;
    }
529466
public function addFields($fields)
    {
        if ($fields instanceof FieldsBuilder) {
            $builder = clone $fields;
            $fields = $builder->getFields();
        }

        foreach ($fields as $field) {
            $this->getFieldManager()->pushField($field);
        }

        return $this;
    }
1328816
public function setFields(array $fields)
    {
        foreach ($fields as $name => $value) {
            $this->setField($name, $value);
        }

        $this->prepareQuery();

        return $this;
    }