diff --git a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php index 89acbde9..9fed5a85 100644 --- a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php +++ b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php @@ -58,9 +58,19 @@ class ExportCustomersToExcelController public function paymentTransactions(Request $request){ $exportsTransactions = new ExportsPaymentTransactions($request); - $response = $exportsTransactions->download('payment-transactions.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); + $exportFileName = 'payment-transactions.xls'; $filesystemDriver = Storage::getDefaultDriver(); - if($filesystemDriver !== 's3'){ + if($filesystemDriver === 's3'){ + $exportDirectory = storage_path('app/export'); // Update this with the actual directory path + if (!file_exists($exportDirectory)) { + mkdir($exportDirectory, 0755, true); + } + $localPath = $exportDirectory . '/' . $exportFileName; + $response = $exportsTransactions->store($localPath, null, Excel::XLS); + return response()->file($localPath, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); + } + else{ + $response = $exportsTransactions->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); ob_end_clean(); } return $response; @@ -118,3 +128,4 @@ class ExportCustomersToExcelController return $response; } } +