public function build($collection, array $fields, $config = [])
    {
        $this->config = $config;
        $csv = $this->writer;
        $headers = [];

        foreach ($fields as $key => $field) {
            $headers[] = $field;

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

        if (is_a($collection, EloquentCollection::class)) {
            $this->isEloquentCollection = true;
        }

        $this->addHeader($csv, $headers);
        $this->addCsvRows($collection, $fields, $csv);

        return $this;
    }