public function updateDatabase(Response $response) { $arrayUpdate = ['address1' => $response->getAddress(), 'neighborhood' => $response->getNeighborhood(), 'city' => $response->getCity(), 'state' => $response->getState(), 'zip' => $response->getPostalCode(), 'country_code' => $this->getModel()->country_code]; $validation = $this->addressRepository->validateRequest(null, $arrayUpdate); if (is_array($validation)) { return false; } if ($this->addressOutSync) { $this->addressRepository->update($arrayUpdate, $this->addressOutSync); } else { $this->addressRepository->create($arrayUpdate); } }
/** * @param Request $request * * @return mixed */ public function create(Request $request) { $handleRequest = $this->repository->validateRequest($request); if (is_array($handleRequest)) { throw new StoreResourceFailedException('Invalid params', $handleRequest); } try { $this->validCountry($request->input('country_code', '')); $address = $this->repository->create($request->all()); return $this->response->item($address, new BaseTransformer())->setStatusCode(201); } catch (\Exception $e) { throw new StoreResourceFailedException($e->getMessage()); } }