mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-09-01 19:04:08 +00:00
Export excel file from Laravel Vapor through S3 bucket (code sync from exchange-2.0)
This commit is contained in:
@@ -8,6 +8,8 @@ use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Classes\General\AWSS3Helper;
|
||||
|
||||
class ExportCompanyModuleSummaryController
|
||||
{
|
||||
@@ -24,17 +26,31 @@ class ExportCompanyModuleSummaryController
|
||||
public function export(Request $request) {
|
||||
$exportsCompanyModuleSummary = new ExportsCompanyModuleSummary($request);
|
||||
$exportsCompanyModuleSummary->setParameters($request->route('company_module_id'), $request->input('containerNumber'));
|
||||
$response = $exportsCompanyModuleSummary->download('customerid-markingno.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
$exportFileName = 'customerid-markingno.xls';
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver === 's3'){
|
||||
return response([ 'src' => AWSS3Helper::S3($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'));
|
||||
$response = $exportsOrderSummaryByMarking->download($customer_marking . '_order_summary.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
$exportFileName = $customer_marking . '_order_summary.xls';
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver === 's3'){
|
||||
return response([ 'src' => AWSS3Helper::S3($exportFileName, $exportsOrderSummaryByMarking) ]);
|
||||
}
|
||||
else{
|
||||
$response = $exportsOrderSummaryByMarking->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user