'Updated Company', 'message' => 'You have successfully updated the Company' ]; } /** @var CanUpdateCompany */ private $canUpdateCompany; /** @var UpdatesCompany */ private $updatesCompany; /** @var FetchesCompany */ private $fetchesCompany; /** * UpdateCompanyControllersLogic constructor. * @param CanUpdateCompany $canUpdateCompany * @param UpdatesCompany $updatesCompany * @param FetchesCompany $fetchesCompany */ public function __construct(CanUpdateCompany $canUpdateCompany, UpdatesCompany $updatesCompany, FetchesCompany $fetchesCompany) { $this->canUpdateCompany = $canUpdateCompany; $this->updatesCompany = $updatesCompany; $this->fetchesCompany = $fetchesCompany; } /** * @param Request $request * @return JsonResponse * @throws ErrorException */ public function logic(Request $request) : JsonResponse { $object = new CompanyObject($request->input('name'), $request->input('reference'), $request->input('business_type'), $request->input('type')); $this->canUpdateCompany->passes($object); $query = $this->fetchesCompany->execute(['id' => $request->route('id')]); $query = $this->updatesCompany->execute($query, $object); return $this->resourceResponse(new CompanyResource($query)); } }