'Created Company Contact Number', 'message' => 'You have successfully created the Company Contact Number' ]; } /** @var FetchesCompany */ private $fetchesCompany; /** @var CreatesContact */ private $createsContact; /** @var CreateContactProcessor */ private $createContactProcessor; /** * UpdateCompanyControllersLogic constructor. * @param FetchesCompany $fetchesCompany * @param CreatesContact $createsContact * @param CreateContactProcessor $createContactProcessor */ public function __construct(FetchesCompany $fetchesCompany, CreatesContact $createsContact, CreateContactProcessor $createContactProcessor) { $this->fetchesCompany = $fetchesCompany; $this->createsContact = $createsContact; $this->createContactProcessor = $createContactProcessor; } /** * @param Request $request * @return JsonResponse * @throws ErrorException */ public function logic(Request $request) : JsonResponse { $company = $this->fetchesCompany->execute(['id' => $request->input('companyId')]); $contact = new ContactObject( $company->reference, $request->input('contactNumber'), $company->email, $company->wechat_id ); $this->createContactProcessor->execute($contact, $company); return $this->resourceResponse(new CompanyResource($company)); } }