diff --git a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php index ae266913..d5c45e1f 100644 --- a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php +++ b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php @@ -58,7 +58,7 @@ class ExportCustomersToExcelController public function paymentTransactions(Request $request){ $exportsTransactions = new ExportsPaymentTransactions($request); - $exportFileName = 'payment-transactions.xlsx'; + $exportFileName = 'payment-transactions.xls'; $filesystemDriver = Storage::getDefaultDriver(); if($filesystemDriver === 's3'){ @@ -68,15 +68,24 @@ class ExportCustomersToExcelController //Step 2: Read and Download from S3 $fileContent = Storage::disk('s3')->get($filePathForS3); - $exportDirectory = storage_path('app/temp'); // Update this with the actual directory path - if (!file_exists($exportDirectory)) { - mkdir($exportDirectory, 0755, true); - } - $localPath = $exportDirectory . '/' . $exportFileName; - file_put_contents($localPath, $fileContent); + // $exportDirectory = storage_path('app/temp'); // Update this with the actual directory path + // if (!file_exists($exportDirectory)) { + // mkdir($exportDirectory, 0755, true); + // } + // $localPath = $exportDirectory . '/' . $exportFileName; + // file_put_contents($localPath, $fileContent); - //Step 3: Return - return response()->file($localPath, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); + // //Step 3: Return + // return response()->file($localPath, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); + + $headers = [ + 'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'Content-Disposition' => 'attachment; filename="' . $exportFileName . '"', + ]; + + // Return the file content as a response with the headers + return response($fileContent, 200) + ->withHeaders($headers); } else{ $response = $exportsTransactions->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);