getRequest()->getParam('id'); $status = (string)$this->getRequest()->getParam('status'); $allowed = [VatApplication::STATUS_PENDING, VatApplication::STATUS_APPROVED, VatApplication::STATUS_REJECTED]; $application = $this->factory->create(); $this->resource->load($application, $id); if (!$application->getId() || !in_array($status, $allowed, true)) { $this->messageManager->addErrorMessage(__('Unable to review this VAT application.')); return $this->resultRedirectFactory->create()->setPath('*/*/index'); } try { $admin = $this->authSession->getUser(); $application->addData([ 'status' => $status, 'review_note' => trim((string)$this->getRequest()->getParam('review_note')) ?: null, 'reviewed_by' => $admin ? (int)$admin->getId() : null, 'reviewed_at' => $this->dateTime->gmtDate(), ]); $this->resource->save($application); $this->messageManager->addSuccessMessage(__('The VAT application review has been saved.')); } catch (\Throwable $exception) { $this->messageManager->addExceptionMessage($exception, __('Unable to save the VAT application review.')); } return $this->resultRedirectFactory->create()->setPath('*/*/view', ['id' => $id]); } }