'Approve Document', 'message' => 'You have successfully approved the Document' ]; } /** @var CanUpdateDocument */ private $canUpdateDocument; /** @var ApprovesDocument */ private $approvesDocument; /** @var FetchesDocument */ private $fetchesDocument; /** * UpdateStandardSegmentConstantLogic constructor. * @param CanUpdateDocument $canUpdateDocument * @param ApprovesDocument $approvesDocument * @param FetchesDocument $fetchesDocument */ public function __construct( canUpdateDocument $canUpdateDocument, ApprovesDocument $approvesDocument, FetchesDocument $fetchesDocument ) { $this->canUpdateDocument = $canUpdateDocument; $this->approvesDocument = $approvesDocument; $this->fetchesDocument = $fetchesDocument; } /** * @param Request $request * @return JsonResponse * @throws ErrorException */ public function logic(Request $request) : JsonResponse { try { $document = $this->fetchesDocument->execute(['id' => $request->route('id')]); $this->canUpdateDocument->passes($document); $document_query = $this->approvesDocument->execute($document); return $this->resourceResponse(new DocumentResource($document_query)); } catch (\Exception $exception){ throw new ErrorException($exception->getMessage(), $exception->getCode()); } } }