'Regenerate Storage E-Invoice', 'message' => 'You have successfully regenerated storage e-invoice' ]; } /** @var FetchesTransaction */ private $fetchesTransaction; /** @var CreateStorageEInvoiceDocProcessor */ private $createStorageEInvoiceDocProcessor; /** * @param FetchesTransaction $fetchesTransaction * @param CreateStorageEInvoiceDocProcessor $createStorageEInvoiceDocProcessor */ public function __construct(FetchesTransaction $fetchesTransaction, CreateStorageEInvoiceDocProcessor $createStorageEInvoiceDocProcessor) { $this->fetchesTransaction = $fetchesTransaction; $this->createStorageEInvoiceDocProcessor = $createStorageEInvoiceDocProcessor; } public function logic(Request $request) : JsonResponse { $invoice = $this->fetchesTransaction->execute(['id' => $request->route('invoice_id')]); $invoice->documents()->where('document_type', DocumentType::STORAGE_EINVOICE)->delete(); $this->createStorageEInvoiceDocProcessor->execute($invoice); return $this->response([]); } }