'Deleted Project Milestone', 'message' => 'You have successfully deleted a Project Milestone' ]; } /** @var CanDeleteProjectMilestone */ private $canDeleteProjectMilestone; /** @var DeletesProjectMilestone */ private $deletesProjectMilestone; /** @var FetchesProjectMilestone */ private $fetchesProjectMilestone; /** * DeleteProjectMilestoneControllerLogic constructor. * @param CanDeleteProjectMilestone $canDeleteProjectMilestone * @param DeletesProjectMilestone $deletesProjectMilestone * @param FetchesProjectMilestone $fetchesProjectMilestone */ public function __construct(CanDeleteProjectMilestone $canDeleteProjectMilestone, DeletesProjectMilestone $deletesProjectMilestone, FetchesProjectMilestone $fetchesProjectMilestone) { $this->canDeleteProjectMilestone = $canDeleteProjectMilestone; $this->deletesProjectMilestone = $deletesProjectMilestone; $this->fetchesProjectMilestone = $fetchesProjectMilestone; } /** * @param Request $request * @return JsonResponse * @throws ErrorException */ public function logic(Request $request) : JsonResponse { try { $this->canDeleteProjectMilestone->passes(); $query = $this->fetchesProjectMilestone->execute(['id' => $request->route('id')]); $this->deletesProjectMilestone->execute($query); return $this->response([]); } catch (\Exception $exception){ throw new ErrorException($exception->getMessage(), $exception->getCode()); } } }