'Updated Project Milestone', 'message' => 'You have successfully updated the Project Milestone' ]; } /** @var CanUpdateProjectMilestone */ private $canUpdateProjectMilestone; /** @var UpdatesProjectMilestone */ private $updatesProjectMilestone; /** @var FetchesProjectMilestone */ private $fetchesProjectMilestone; /** * UpdateProjectMilestoneControllerLogic constructor. * @param CanUpdateProjectMilestone $canUpdateProjectMilestone * @param UpdatesProjectMilestone $updatesProjectMilestone * @param FetchesProjectMilestone $fetchesProjectMilestone */ public function __construct(CanUpdateProjectMilestone $canUpdateProjectMilestone, UpdatesProjectMilestone $updatesProjectMilestone, FetchesProjectMilestone $fetchesProjectMilestone) { $this->canUpdateProjectMilestone = $canUpdateProjectMilestone; $this->updatesProjectMilestone = $updatesProjectMilestone; $this->fetchesProjectMilestone = $fetchesProjectMilestone; } /** * @param Request $request * @return JsonResponse * @throws ErrorException */ public function logic(Request $request) : JsonResponse { try { $object = new ProjectMilestoneObject($request->input('project_id'), $request->input('name'), $request->input('order'), $request->input('complete')); $this->canUpdateProjectMilestone->passes($object); $query = $this->fetchesProjectMilestone->execute(['id' => $request->route('id')]); $query = $this->updatesProjectMilestone->execute($query, $object); return $this->resourceResponse(new ProjectMilestoneResource($query)); } catch (\Exception $exception){ throw new ErrorException($exception->getMessage(), $exception->getCode()); } } }