mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-22 05:53:58 +00:00
Export pdf file from Laravel Vapor through S3 bucket
This commit is contained in:
+11
-1
@@ -8,6 +8,8 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\General\AWSS3Helper;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class DownloadMockUpWhiteFormPdfLogic
|
||||
{
|
||||
@@ -56,6 +58,14 @@ class DownloadMockUpWhiteFormPdfLogic
|
||||
|
||||
DB::rollBack();
|
||||
|
||||
return $pdf->stream('MockUpWhiteForm.pdf');
|
||||
$exportFileName = 'MockUpWhiteForm.pdf';
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver === 's3'){
|
||||
$pdfContent = $pdf->output();
|
||||
AWSS3Helper::S3PDF($exportFileName, $pdfContent);
|
||||
}
|
||||
else{
|
||||
return $pdf->stream($exportFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,9 +150,22 @@
|
||||
return payment.id
|
||||
});
|
||||
|
||||
window.open(this.route('whiteForm.mockUp', this.supplier.id)+'?rate='+this.parameters.rate+'&payments='+JSON.stringify(paymentIds), '_blank');
|
||||
let url = this.route('whiteForm.mockUp', this.supplier.id)+'?rate='+this.parameters.rate+'&payments='+JSON.stringify(paymentIds);
|
||||
if(window.LARAVEL_VAPOR_ENABLED){
|
||||
return fetch(url, {
|
||||
method: 'GET',
|
||||
responseType: 'json',
|
||||
}).then(response => {
|
||||
if (response.src) {
|
||||
window.location.href = response.src;
|
||||
}
|
||||
});
|
||||
}
|
||||
else{
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
}
|
||||
},
|
||||
mixins: [FormHandler]
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user