Skip to content

Commit

Permalink
Merge pull request #1 from JeRabix/patch-1
Browse files Browse the repository at this point in the history
feat: export filename use uuid by default
  • Loading branch information
lee-to authored Nov 3, 2024
2 parents bc7f650 + 42c772d commit 3a1027e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ExportHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Rap2hpoutre\FastExcel\FastExcel;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
use Illuminate\Support\Str;

class ExportHandler extends Handler
{
Expand Down Expand Up @@ -93,12 +94,17 @@ public function getDelimiter(): string
private function generateFilePath(): string
{
$dir = $this->getDir();
$filename = $this->hasFilename() ? $this->filename : $this->getResource()->getUriKey();
$filename = $this->hasFilename() ? $this->filename : $this->getDefaultFilename();
$ext = $this->isCsv() ? 'csv' : 'xlsx';

return sprintf('%s/%s.%s', $dir, $filename, $ext);
}

private function getDefaultFilename(): string
{
return $this->getResource()->getUriKey() . '-' . Str::uuid();
}

/**
* @throws ActionButtonException
* @throws IOException
Expand Down

0 comments on commit 3a1027e

Please sign in to comment.