headers->set('Authorization', 'Bearer '.$token); } public function export(ExportsCustomers $exportsCustomers, Request $request){ return $exportsCustomers->download('customers.csv', Excel::CSV, ['Content-Type' => 'text/csv']); } public function exportCurrencyVendorOrder(ExportCurrencyVendorOrder $exportCurrencyVendorOrder, Request $request){ $exportCurrencyVendorOrder = new ExportCurrencyVendorOrder($request); $response = $exportCurrencyVendorOrder->download('CurrencyVendorOrder.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); ob_end_clean(); return $response; } public function transactions(ExportsTransactions $exportsTransactions, Request $request){ return $exportsTransactions->download('transactions.csv', Excel::CSV, ['Content-Type' => 'text/csv']); } public function nullDebtor(ExportsNullDebtors $exportsNullDebtors, Request $request){ $response = $exportsNullDebtors->download('nullDebtor.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); ob_end_clean(); return $response; } public function paymentTransactions(Request $request){ $exportsTransactions = new ExportsPaymentTransactions($request); $exportFileName = 'payment-transactions.xls'; $filesystemDriver = Storage::getDefaultDriver(); if($filesystemDriver === 's3'){ //Step 1: Upload to S3 $filePathForS3 = 'temp/' . $exportFileName; $exportsTransactions->store($filePathForS3, 's3'); //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); // //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']); ob_end_clean(); } return $response; } public function whiteFormTransactions(Request $request){ $exportsTransactions = new ExportsWhiteFormTransactions($request); $response = $exportsTransactions->download('white-form-transactions.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); ob_end_clean(); return $response; } public function walletTransactions(Request $request){ $exportsTransactions = new ExportsWalletTransactions($request); $response = $exportsTransactions->download('wallet-transactions.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); ob_end_clean(); return $response; } public function invoiceTransactions(Request $request){ $exportsTransactions = new ExportsInvoiceTransactions($request); $response = $exportsTransactions->download('invoice-transactions.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); ob_end_clean(); return $response; } public function receiptTransactions(Request $request){ $exportsTransactions = new ExportsReceiptTransactions($request); $response = $exportsTransactions->download('receipt-transactions.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); ob_end_clean(); return $response; } public function bookingTransactions(ExportsBookingTransactions $exportsBookingTransactions, Request $request){ $response = $exportsBookingTransactions->download('bookingTransactions.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); ob_end_clean(); return $response; } public function leadsData(ExportsLeadsTransactions $exportsLeadsTransactions, Request $request){ $response = $exportsLeadsTransactions->download('leadsData.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); ob_end_clean(); return $response; } public function importedInvoiceMapped(ExportsImportedInvoiceMappeds $exportsImportedInvoiceMappeds, Request $request) { $response = $exportsImportedInvoiceMappeds->download($request->input('fileName').'.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); ob_end_clean(); return $response; } public function importedReceiptMapped(ExportsImportedReceiptMappeds $exportsImportedReceiptMappeds, Request $request) { $response = $exportsImportedReceiptMappeds->download($request->input('fileName').'.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); ob_end_clean(); return $response; } }