createsDocument = $createsDocument; $this->createsFiles = $createsFiles; } /** * @throws MalformedRequestException */ public function execute(Transaction $invoice_transaction) { $view = 'pages.pdfs.shipping_einvoice'; $companyModule = $invoice_transaction->owner->owner->companyModule; $user = $companyModule->employees()->first(); $brn = $companyModule->company->documents->where('document_type', DocumentType::SSM_REGISTRATION)->first(); $lastDayOfMonth = $invoice_transaction->created_at->copy()->endOfMonth(); $documentDate = $lastDayOfMonth; $documentIdentifierPrefix = 'EI#: '; $documentIdentifier = 'NONE'; $transaction_invoice_pdf = LaravelMpdf::loadView($view, ['invoice_transaction' => $invoice_transaction, 'brn' => $brn, 'document_date' => $documentDate, 'document_identifier' => $documentIdentifier, 'document_identifier_prefix' => $documentIdentifierPrefix]); $document_object = new DocumentObject( DocumentType::SHIPPING_EINVOICE, [chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))], '', ApprovalStatus::COMPLETED, 'shipping_einvoice' ); /** @var Document $document */ $document =$this->createsDocument->execute($invoice_transaction, $document_object); $this->createsFiles->execute($document, $document_object); } }