Makes fields

@param Collection $fields
@return string
6774
protected function makeFields(Collection $fields = null)
    {
        if (is_null($fields))
        {
            return '';
        }

        $fields = $fields->pluck('name')->toArray();

        return count($fields) ? "'" . implode("', '", $fields) . "'" : '';
    }
1333071
public function returnedFields($fields) {
		if(empty($this->data['returnedFields'])) {
			$this->data['returnedFields'] = array();
		}
		$this->data['returnedFields'] = array_unique(array_merge($this->data['returnedFields'], (array)$fields));
		return $this;
	}
238893
protected function getFormRules(array $fields)
    {
        $rules = [];

        foreach ($fields as $field) {
            /** @var FieldTypeInterface $field */
            $rules[$field->getName()] = $field->getOption('rules');
        }

        return $rules;
    }
103201
protected function parseField($fields)
    {
        if(!isset($fields[0]))
        {
            return '*';
        }
        $result = [];
        foreach($fields as $k => $v)
        {
            if(is_numeric($k))
            {
                if($v instanceof Field)
                {
                    $field = $v;
                }
                else
                {
                    $field = new Field;
                    $field->setValue($v);
                }
            }
            else
            {
                $field = new Field(null, null, $k, $v);
            }
            $result[] = $field;
        }
        return implode(',', $result);
    }
430069
public function &serialize(...$fields)
    {
        if (!empty($fields)) {
            $this->serialize = array_unique(array_merge($this->serialize, $fields));
        }

        return $this;
    }
942680
public function fields( $fields )
	{
		if ( !is_array( $fields ) && !is_null( $fields ) )
		{
			$fields = array( $fields );
		}
		
		// do nothing if we get nothing
		if ( empty( $fields ) || $fields == array( '*' ) )
		{
			$this->fields = array(); return $this;
		}
		
		$this->fields = $fields;

		// return self so we can continue running the next function
		return $this;
	}
764284
protected function makeSearchableFields(Collection $fields = null, $tableName)
    {
        if (is_null($fields))
        {
            return '';
        }

        $searchables = [];

        foreach ($fields as $field)
        {
            if (intval($field->search_priority) > 0)
            {
                $searchables[] = "'{$tableName}.{$field->name}' => {$field->search_priority}";
            }
        }

        return implode(",", $searchables);
    }
1079380
public function getTitleFields(array $fields)
    {
        $fields = array_map(function ($field) {
            if (str_contains($field, '.')) {
                return object_get($this, $field); // this acts as a delimiter, which we can replace with /
            } else {
                return $this->{$field};
            }
        }, $fields);

        return $fields;
    }
184532
private function cleanFields(array $fields): array
    {
        foreach ($fields['fields'] as &$field) {
            if (array_key_exists('generator', $field[key($field)])) {
                unset($field[key($field)]['generator']);
            }
        }

        unset($fields['section']);
        return $fields;
    }
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;
    }
1270232
protected function fields(array $fields) {
        if (!empty($fields)) {
            if (!is_numeric(key($fields))) {
                $fields = array_keys($fields);
            }
            $this->insertFields = $fields;
        }
        return $this;
    }
243401
public static function quoteFields($fields) {
        $fieldArr = is_array($fields) ? $fields : explode(',', $fields);
        $resultFieldArr = array();
        foreach ($fieldArr as $field) {
            $resultFieldArr[] = self::quoteField($field);
        }

        return implode(', ', $resultFieldArr);
    }
233225
public function fields($fields = [])
    {
        $this->builder->select([]);
        $this->casts = [];

        if (empty($fields)) {
            foreach ($this->model->fields() as $field) {
                $this->assignField($field);
            }

            return $this;
        }

        foreach ($fields as $field) {
            $this->assignField($this->model->field($field));
        }

        return $this;
    }
259872
private static function getFieldTypeArray($fields)
    {
        if (count($fields) === 0) {
            return;
        }

        $types = array();

        foreach ($fields as &$field) {
            $types[] = $field->type;
        }

        return $types;
    }
797447
public function buildEntityFields($fields)
    {
        $aliases = [];
        $dottedFields = [];

        if (!$this->isArray($fields)) {
            $cacheKey = $fields;
            if (array_key_exists($cacheKey, self::$cache)) {
                return self::$cache[$cacheKey];
            }

            $fields = $this->str($fields);

            if ($fields->contains('[')) {
                $fields = $this->parseGroupedNestedFields($fields);
            }

            $fields = $fields->explode(',')->filter()->map('trim')->val();
        } else {
            $cacheKey = serialize($fields);
            if (array_key_exists($cacheKey, self::$cache)) {
                return self::$cache[$cacheKey];
            }

            // Check if asterisk is present and replace it with actual attribute names
            if ($this->arr($fields)->keyExists('*')) {
                unset($fields['*']);
                $defaultFields = $this->str($this->getDefaultAttributes())->explode(',')->filter()->map('trim')->flip()->val();
                $fields = $this->arr($fields)->merge($defaultFields)->val();
            }

            return self::$cache[$cacheKey] = [
                'fields'       => $fields,
                'aliases'      => $aliases,
                'dottedFields' => $dottedFields
            ];
        }

        $parsedFields = $this->arr(['id' => true]);
        $unsetFields = [];

        foreach ($fields as $f) {
            $f = $this->str($f);

            if ($f->contains('@')) {
                list($f, $alias) = $f->explode('@')->val();
                $aliases[$f] = $alias;
                $f = $this->str($f);
            }

            $dottedFields[] = $f->val();

            if ($f->startsWith('!')) {
                $unsetFields[] = $f->trimLeft('!')->val();
                continue;
            }

            if ($f->val() == '*') {
                $defaultFields = $this->str($this->getDefaultAttributes())->explode(',')->filter()->map('trim')->val();
                foreach ($defaultFields as $df) {
                    $this->buildFields($parsedFields, $this->str($df));
                }
                continue;
            }
            $this->buildFields($parsedFields, $f);
        }

        foreach ($unsetFields as $field) {
            $parsedFields->removeKey($field);
        }

        return self::$cache[$cacheKey] = [
            'fields'       => $parsedFields->val(),
            'aliases'      => $aliases,
            'dottedFields' => $dottedFields
        ];
    }
484049
public function fields($fields)
    {
        if (is_array($fields) || $fields === null) {
            $this->fields = $fields;
        } else {
            $this->fields = func_get_args();
        }
        return $this;
    }
962854
public function formCreate($fields)
    {
        $output = '';

        foreach ($fields as $f) {
            $ucF = ucfirst($f);

            $input_attr = [
                'class' => 'form-control',
                'id' => 'createItem'.$f,
                'name' => $f,
            ];

            $label = $this->humanReadableField($ucF);

            $output .= '<fieldset class="form-group">';

            $output .= '<label for="'.$input_attr['id'].'">'.$label.'</label>';

            if ($this->isIdField($f)) {
                $input_attr['type'] = 'select';

                $output .= '<select ';
                foreach ($input_attr as $attr => $value) {
                    $output .= "{$attr}='{$value}'";
                }

                $relation = $this->crudApi->getRelatedModel($f);
                $output .= '>';

                $output .= $this->crudApi->getRelatedOptions($relation);

                $output .= '</select>';
            } else {
                $input_attr['type'] = 'text';

                $output .= '<input ';
                foreach ($input_attr as $attr => $value) {
                    $output .= "{$attr}='{$value}'";
                }
                $output .= '>';
            }

            $output .= '</fieldset>';
        }

        return $output;
    }