Skip to content

Commit 044470a

Browse files
authored
added method for delete after download the file (#20)
1 parent 1bfb9a4 commit 044470a

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

.idea/laravel-flatfiles.iml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/php.xml

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88

9+
## v4.0.2
10+
### Added
11+
- Support for deleting export file after download
12+
913
## v4.0.1
1014
### Added
1115
- Add support for LazyCollections

src/FlatfileExport.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function addRows(Enumerable $models): void
112112
* @param Model $model
113113
* @param string|array $relations Name of child relation in model
114114
* @param string $alias Name of attribute set with each model
115-
* @param bool $skipWithoutRelations If there is no relation, skip line or not?
115+
* @param bool $skipWithoutRelations If there is no relation, skip line or not?
116116
* @return void
117117
* @throws CannotInsertRecord
118118
*/
@@ -341,4 +341,15 @@ public function downloadResponse(string $filename = null, array $headers = [])
341341
{
342342
return $this->disk()->download($this->pathToFileOnDisk, $filename, $headers);
343343
}
344+
345+
/**
346+
* @param string|null $filename
347+
* @param array $headers
348+
*
349+
* @return BinaryFileResponse
350+
*/
351+
public function downloadAndDeleteAfterResponse(string $filename = null, array $headers = [])
352+
{
353+
return response()->download($this->disk()->path($filename), $filename, $headers)->deleteFileAfterSend(true);
354+
}
344355
}

0 commit comments

Comments
 (0)