File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 44
55use Illuminate \Support \Facades \Bus ;
66use Illuminate \Support \Facades \Storage ;
7+ use Illuminate \Support \Str ;
78use Livewire \Component ;
89
910class ExportButtonComponent extends Component
@@ -47,16 +48,31 @@ public function updateExportProgress()
4748
4849 public function downloadExport ()
4950 {
50- return Storage::download ('exports/ ' .$ this ->batchJobId .'. ' .$ this ->getType (), $ this ->filename );
51+ return Storage::download ('exports/ ' .$ this ->batchJobId .'. ' .$ this ->getType (), $ this ->getFilename () );
5152 }
5253
5354 public function render ()
5455 {
55- return view ('datatables-export::export-button ' );
56+ return view ('datatables-export::export-button ' , [
57+ 'fileType ' => $ this ->getType ()
58+ ]);
5659 }
5760
5861 protected function getType (): string
5962 {
63+ if (Str::endsWith ($ this ->filename , ['csv ' , 'xlsx ' ])) {
64+ return pathinfo ($ this ->filename , PATHINFO_EXTENSION );
65+ }
66+
6067 return $ this ->type == 'csv ' ? 'csv ' : 'xlsx ' ;
6168 }
69+
70+ protected function getFilename ()
71+ {
72+ if (Str::endsWith ($ this ->filename , ['csv ' , 'xlsx ' ])) {
73+ return $ this ->filename ;
74+ }
75+
76+ return null ;
77+ }
6278}
Original file line number Diff line number Diff line change 33 x-on:submit.prevent ="
44 $refs.exportBtn.disabled = true;
55 var url = window._buildUrl(LaravelDataTables['{{ $tableId } } '], 'exportQueue');
6- $.get(url + '&exportType={{ $type } } ').then(function(exportId) {
6+ $.get(url + '&exportType={{ $fileType } } ').then(function(exportId) {
77 $wire.export(exportId)
88 }).catch(function(error) {
99 $wire.exportFinished = true;
You can’t perform that action at this time.
0 commit comments