headers->set('Authorization', 'Bearer '.$token); } public function export(Request $request) { $exportsCompanyModuleSummary = new ExportsCompanyModuleSummary($request); $exportsCompanyModuleSummary->setParameters($request->route('company_module_id'), $request->input('containerNumber')); $exportFileName = 'customerid-markingno.xls'; $filesystemDriver = Storage::getDefaultDriver(); if($filesystemDriver === 's3'){ return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsCompanyModuleSummary) ]); } else{ $response = $exportsCompanyModuleSummary->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); ob_end_clean(); return $response; } } public function exportOrderSummaryByMarking(Request $request) { $exportsOrderSummaryByMarking = new ExportsOrderSummaryByMarking($request); $customer_marking = $request->route('marking'); $exportsOrderSummaryByMarking->setParameters($customer_marking, $request->input('dateFrom'), $request->input('dateTo')); $exportFileName = $customer_marking . '_order_summary.xls'; $filesystemDriver = Storage::getDefaultDriver(); if($filesystemDriver === 's3'){ return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsOrderSummaryByMarking) ]); } else{ $response = $exportsOrderSummaryByMarking->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); ob_end_clean(); return $response; } } public function exportSegmentCustomers(Request $request) { $exportsSegmentCustomers = new ExportsSegmentCustomers($request); $customer_marking = $request->route('companyMarking'); $segment = $request->route('segment'); $exportsSegmentCustomers->setParameters($customer_marking, $segment); $segment_name = Segment::find($request->route('segment'))->name; $segment_name = $segment_name ? strtolower(str_replace(' ', '_', $segment_name)): 'segment'; $exportFileName = $segment_name . '_customers.xls'; $filesystemDriver = Storage::getDefaultDriver(); if ($filesystemDriver === 's3') { return response(['src' => AWSS3Helper::S3Exportable($exportFileName, $exportsSegmentCustomers)]); } else { $response = $exportsSegmentCustomers->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); ob_end_clean(); return $response; } } public function exportAllCustomersInfoForLarkSystem(Request $request) { $password = $request->input('password'); if ($password !== 'all_customers_data') { return response()->json(['error' => 'Invalid password'], 403); } $exportsAllCustomersInfoForLarkSystem = new ExportsAllCustomersInfoForLarkSystem($request); $exportFileName = 'shipping_all_customers_info_for_lark_system.xls'; $filesystemDriver = Storage::getDefaultDriver(); if ($filesystemDriver === 's3') { return response(['src' => AWSS3Helper::S3Exportable($exportFileName, $exportsAllCustomersInfoForLarkSystem)]); } else { $response = $exportsAllCustomersInfoForLarkSystem->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); ob_end_clean(); return $response; } } }