Merge branch 'dillon/34.8-jenkins-vapor' into vapor/development

This commit is contained in:
Dillon Ngo
2024-10-16 13:28:08 +08:00
@@ -8,6 +8,7 @@ use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\DocumentType;
use App\Models\Document;
use Illuminate\Support\Facades\Log;
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
use Webklex\PDFMerger\Facades\PDFMergerFacade as PDFMerger;
use Illuminate\Support\Facades\Storage;
@@ -61,10 +62,18 @@ class CreateInvoiceDocumentProcessor
$oMerger->addPDF(storage_path('app/documents/temp.pdf'), 'all');
$filesystemDriver = Storage::getDefaultDriver();
foreach ($purchaseOrderDocuments as $document){
$localFilePath = storage_path('app/documents/' . $document->files()->first()->file->file_info->original->file);
$currentFile = $document->files()->first()->file->file_info->original->file;
if($filesystemDriver === 's3'){
Log::info('CreateInvoiceDocumentProcessor 1: ' . $currentFile);
$fileContent = Storage::disk('s3')->get($currentFile);
Storage::put('app/documents/' . $currentFile, $fileContent);
}
$localFilePath = storage_path('app/documents/' . $currentFile);
$oMerger->addPDF($localFilePath, 'all');
if($filesystemDriver === 's3'){
$filePathForS3 = 'documents/'.$document->files()->first()->file->file_info->original->file;
$filePathForS3 = 'documents/'.$currentFile;
Log::info('CreateInvoiceDocumentProcessor 2: ' . $filePathForS3);
Storage::disk('s3')->put($filePathForS3, file_get_contents($localFilePath));
}
}