|
17 | 17 | use Illuminate\Support\Arr; |
18 | 18 | use Illuminate\Support\Facades\Auth; |
19 | 19 | use Illuminate\Support\Facades\File; |
| 20 | +use Illuminate\Support\Facades\Storage; |
20 | 21 | use Illuminate\Support\Str; |
21 | 22 | use PhpOffice\PhpSpreadsheet\Shared\Date; |
| 23 | +use Yajra\DataTables\Exceptions\Exception; |
22 | 24 | use Yajra\DataTables\Html\Column; |
23 | 25 | use Yajra\DataTables\Services\DataTable; |
24 | 26 |
|
@@ -74,15 +76,14 @@ public function handle() |
74 | 76 | $dataTable = app()->call([$oTable, 'dataTable'], compact('query')); |
75 | 77 | $dataTable->skipPaging(); |
76 | 78 |
|
77 | | - $exportPath = config('datatables-export.path', storage_path('app/exports')); |
| 79 | + $type = Str::startsWith(request('exportType'), Type::CSV) ? Type::CSV : Type::XLSX; |
| 80 | + $disk = config('datatables-export.disk', 'local'); |
| 81 | + $filename = $this->batchId.'.'.$type; |
78 | 82 |
|
79 | | - if (! File::isDirectory($exportPath)) { |
80 | | - File::makeDirectory($exportPath); |
81 | | - } |
| 83 | + $path = Storage::disk($disk)->path($filename); |
82 | 84 |
|
83 | | - $type = Str::startsWith(request('exportType'), Type::CSV) ? Type::CSV : Type::XLSX; |
84 | 85 | $writer = WriterEntityFactory::createWriter($type); |
85 | | - $writer->openToFile($exportPath.'/'.$this->batchId.'.'.$type); |
| 86 | + $writer->openToFile($path); |
86 | 87 |
|
87 | 88 | $columns = $oTable->html()->getColumns()->filter->exportable; |
88 | 89 | $writer->addRow( |
|
0 commit comments