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;
    }
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;
    }
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 ; }
Sets field names which will be read

@param array $fields

@return $this
Sets field names which will be read