Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Concerns/Exportable.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ public function download(?string $filename = null): StreamedResponse
return CsvExporter::download($this, $this->getFilename($filename));
}

/**
* @param bool $asString
*
* @return mixed
*/
public function stream(bool $asString = false): mixed
{
return CsvExporter::stream($this, $asString);
}

/**
* @param string|null $filename
* @param string|null $disk
Expand Down
17 changes: 17 additions & 0 deletions src/CsvExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,23 @@ public function download(object $exportable, string $filename): StreamedResponse
return $this->service->download($exportable, $filename);
}

/**
* @param object $exportable
* @param bool $asString
*
* @throws InvalidCellValueException
*/
public function stream(object $exportable, bool $asString = false)
{
$streamResponse = $this->service->stream($exportable);

if ($asString) {
return stream_get_contents($streamResponse);
}

return $streamResponse;
}

/**
* @param object $exportable
* @param string $filename
Expand Down
10 changes: 10 additions & 0 deletions src/Services/ExportableService.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ function () use ($stream) {
);
}

/**
* @param object $exportable
*
* @throws InvalidCellValueException
*/
public function stream(object $exportable)
{
return $this->getStream($exportable);
}

/**
* @param object $exportable
* @param string $filename
Expand Down