Create approve shipping invoice endpoint

This commit is contained in:
ahmedsophyudden
2022-06-18 22:51:15 +08:00
parent 6873ddb7cf
commit b4dcc0f049
5 changed files with 110 additions and 33 deletions
@@ -145,24 +145,6 @@ class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic
/** @var Transaction $invoice_transaction */
$invoice_transaction = $this->updatesTransaction->execute($invoice_transaction, $object);
$document = $invoice_transaction->documents->where('document_type', DocumentType::SHIPPING_INVOICE)->first();
$files = $document->files;
$invoice_transaction = $this->fetchesTransaction->execute(['id' => $invoice_transaction->id]);
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice_transaction]);
$file_object = new FileObject(chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output())));
$filePath = $files[0]->file->path.'/'.$files[0]->file->filename;
if(Storage::disk('documents')->exists($filePath)){
Storage::disk('documents')->delete($filePath);
}
Storage::disk('documents')->put($filePath, $file_object->getDecodedData());
return $this->response([]);
}