'Create Supplier Transactions', 'message' => 'You have successfully created currency supplier transactions' ]; } /** @var FetchesCompany */ private $fetchesCompany; /** @var CreateSupplierTransactionProcessor */ private $createSupplierTransactionProcessor; /** @var CreatesDocument */ private $createsDocument; /** @var CreatesFiles */ private $createsFile; /** * CreateSupplierTransactionLogic constructor. * @param FetchesCompany $fetchesCompany * @param CreateSupplierTransactionProcessor $createSupplierTransactionProcessor * @param CreatesDocument $createsDocument * @param CreatesFiles $createsFile */ public function __construct(FetchesCompany $fetchesCompany, CreateSupplierTransactionProcessor $createSupplierTransactionProcessor, CreatesDocument $createsDocument, CreatesFiles $createsFile) { $this->fetchesCompany = $fetchesCompany; $this->createSupplierTransactionProcessor = $createSupplierTransactionProcessor; $this->createsDocument = $createsDocument; $this->createsFile = $createsFile; } public function logic(Request $request) : JsonResponse { $supplier = $this->fetchesCompany->execute(['id' => $request->route('id')]); $rate = $request->input('rate'); $payments = $request->input('payments'); $this->createSupplierTransactionProcessor->execute($supplier, $rate, $payments); if(!count($this->createSupplierTransactionProcessor->getBills())) return $this->response([]); $pdf = LaravelMpdf::loadView('pages.pdfs.currency_vendor_order', ['transactions' => $this->createSupplierTransactionProcessor->getBills(), 'transferFeeTransactions' => $this->createSupplierTransactionProcessor->getTransferTransactions(), 'supplier' => $supplier]); $object = new DocumentObject( DocumentType::CURRENCY_VENDOR_ORDER, [chunk_split('data:application/pdf;base64,'.base64_encode($pdf->output()))], '', ApprovalStatus::COMPLETED, 'currency_vendor_order' ); /** @var Document $document */ $document = $this->createsDocument->execute($supplier, $object); $this->createsFile->execute($document, $object); return $this->response([]); } }