Skip to content

Commit

Permalink
Add string as fallback option to Excel so named params can be used wi…
Browse files Browse the repository at this point in the history
…th the facade
  • Loading branch information
patrickbrouwers committed Jan 16, 2024
1 parent 45e3548 commit 81c921d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .phpunit.cache/test-results

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/Excel.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,17 @@ public function download($export, string $fileName, string $writerType = null, a

/**
* {@inheritdoc}
* @param string|null $disk Fallback for usage with named properties
*/
public function store($export, string $filePath, string $diskName = null, string $writerType = null, $diskOptions = [])
public function store($export, string $filePath, string $diskName = null, string $writerType = null, $diskOptions = [], string $disk = null)
{
if ($export instanceof ShouldQueue) {
return $this->queue($export, $filePath, $diskName, $writerType, $diskOptions);
return $this->queue($export, $filePath, $diskName ?: $disk, $writerType, $diskOptions);
}

$temporaryFile = $this->export($export, $filePath, $writerType);

$exported = $this->filesystem->disk($diskName, $diskOptions)->copy(
$exported = $this->filesystem->disk($diskName ?: $disk, $diskOptions)->copy(
$temporaryFile,
$filePath
);
Expand Down
36 changes: 20 additions & 16 deletions src/Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
interface Exporter
{
/**
* @param object $export
* @param string|null $fileName
* @param string $writerType
* @param array $headers
* @param object $export
* @param string|null $fileName
* @param string $writerType
* @param array $headers
*
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*
* @throws \PhpOffice\PhpSpreadsheet\Exception
Expand All @@ -17,11 +18,12 @@ interface Exporter
public function download($export, string $fileName, string $writerType = null, array $headers = []);

/**
* @param object $export
* @param string $filePath
* @param string|null $disk
* @param string $writerType
* @param mixed $diskOptions
* @param object $export
* @param string $filePath
* @param string|null $diskName
* @param string $writerType
* @param mixed $diskOptions
*
* @return bool
*
* @throws \PhpOffice\PhpSpreadsheet\Exception
Expand All @@ -30,18 +32,20 @@ public function download($export, string $fileName, string $writerType = null, a
public function store($export, string $filePath, string $disk = null, string $writerType = null, $diskOptions = []);

/**
* @param object $export
* @param string $filePath
* @param string|null $disk
* @param string $writerType
* @param mixed $diskOptions
* @param object $export
* @param string $filePath
* @param string|null $disk
* @param string $writerType
* @param mixed $diskOptions
*
* @return \Illuminate\Foundation\Bus\PendingDispatch
*/
public function queue($export, string $filePath, string $disk = null, string $writerType = null, $diskOptions = []);

/**
* @param object $export
* @param string $writerType
* @param object $export
* @param string $writerType
*
* @return string
*/
public function raw($export, string $writerType);
Expand Down
3 changes: 2 additions & 1 deletion src/Fakes/ExcelFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ public function download($export, string $fileName, string $writerType = null, a

/**
* {@inheritdoc}
* @param string|null $diskName Fallback for usage with named properties
*/
public function store($export, string $filePath, string $disk = null, string $writerType = null, $diskOptions = [])
public function store($export, string $filePath, string $disk = null, string $writerType = null, $diskOptions = [], string $diskName = null)
{
if ($export instanceof ShouldQueue) {
return $this->queue($export, $filePath, $disk, $writerType);
Expand Down

0 comments on commit 81c921d

Please sign in to comment.