组合查询字段
@param array $fields 推荐格式：array('id','name','pass')
@return $this
544018
public static function fields($fields) {

        $arr = array();
        if ( is_string($fields) ) {
            $fields = explode(',', $fields);
        }
        foreach ( $fields as $key => $value ) {
            $arr[trim($value)] = 1;
        }
        return $arr;
    }
108689
public function fields(array $fields)
    {
        foreach ($fields as $field => &$value) {
            $value = $value ? 1 : -1;
        }

        $this->fields = array_merge($this->fields, $fields);

        return $this;
    }
223393
public function required($fields)
    {
        Arguments::define(
            Boa::either(Boa::string(), Boa::arrOf(Boa::string()))
        )->check($fields);

        if (!is_array($fields)) {
            $fields = [$fields];
        }

        $this->required = $this->required->append(ArrayList::of($fields));

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

            $this->addField($field);
        }

        return $this;
    }
539768
public function sort(array $fields)
	{
		$sortFields = [];
		foreach ($fields as $field => $value) {
			// Simplest form, just a field name.
			if (is_numeric($field) && !is_array($value)) {
				$sortFields[] = $value;
			} // Field with direction and/or other options.
			else {
				$sortFields[] = [$field => $value];
			}
		}

		$this->set('sort', $sortFields);

		return $this;
	}
1338608
public function addField(Field ...$fields)
    {
        collect($fields)->map(function ($field) {
            $this->group['fields']->put($field->key(), $field->get());
        });

        return $this;
    }
882044
public function setOptional($fields)
    {

        if (empty($fields) === false) {

            if (is_array($fields) === true) {
                $this->optionalFields = implode(',', $fields);
            } else {
                $this->optionalFields = $fields;

            }
        }

        return $this;

    }
109505
protected function setHtmlType(array &$fields)
    {
        foreach ($fields as $field) {
            $field->htmlType = $this->getHtmlType($field->getEloquentDataMethod());
        }

        return $this;
    }
20990
public function fields(array $fields)
    {
        $newFields = array();
        $this->fields = '';
        $this->fieldsArguments = array();

        foreach ($fields as $field) {
            if (is_scalar($field)) {
                $newFields[] = '?f:alias:.?f';
                $this->fieldsArguments[] = $field;
            } else {
                if (!isset($field[0]) or !isset($field[1]) or !is_array($field[1])) {
                    throw new \BadMethodCallException('Must be exist 0 and 1 index in array and second one must be an array');
                }
                $newFields[] = $field[0];
                $this->fieldsArguments = array_merge($this->fieldsArguments, $field[1]);
            }
        }

        $this->fields = implode(', ', $newFields);

        return $this;
    }
43059
public function setFields(array $fields)
    {
        $this->checkValidLoader();

        // Flatten
        $this->loaders[ $this->contextLoader ] = [];
        $this->addFields($fields);

        return $this;
    }
53753
protected function append($fields, string $field)
    {
        // 转换为字段列表
        $fields = $this->table->createFields($fields);

        // 如果是*,不用附加了
        if ($fields == '*') {
            return $fields;
        }

        // 分解为数组
        $fieldsArr = explode(',', $fields);

        // 如果要附加的字段已经在里面了
        if (in_array($field, $fieldsArr)) {
            return $fields;
        }

        // 附加一个字段
        $fieldsArr[] = $field;

        // 返回字段数组
        return $fieldsArr;
    }
1318081
public function addFields(array $fields)
    {
        $oldFields = $this->_queryBuilder->getFields() ? $this->_queryBuilder->getFields() : array();
        $newFields = array_merge($oldFields, $fields);
        $this->setFields($newFields);
        return $this;
    }
1151609
public function when($condition, $fields)
    {
        $this->getChildren()->mergeSchema([
            $this->normalizeCondition($condition) => $fields,
        ]);

        return $this;
    }
968439
public function addKey($name, array $fields)
    {
        //Argument 1 must be a string
        Argument::i()->test(1, 'string');
        
        $this->keys[$name] = $fields;
        return $this;
    }
1154731
public function asc($fields) {
        if (is_array($fields)) {
            $this->_order = ' ORDER BY ' . implode($fields, ', ') . ' ASC';
        } else {
            $this->_order = ' ORDER BY ' . $fields . ' ASC';
        }
         
        return $this;
    }
1358694
public function setMapping(array $fields = [])
    {
        $allowedFields = ['backend', 'page', 'navigation', 'date', 'forward', 'custom1', 'custom2', 'custom3', 'custom4', 'custom5'];
        foreach ($fields as $field => $value) {
            if (!$value || !in_array($field, $allowedFields)) {
                continue;
            }
            if ($field === 'date' && is_string($value)) {
                $value = new \DateTime($value);
            }
            $this->$field = $value;
        }

        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;
	}