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 * @param $id * * @throws UpdateResourceFailedException * * @return mixed */ public function update(Request $request, $id) { $address = $this->repository->findBy('_id', $id); if (!$address) { throw new UpdateResourceFailedException('Register not found'); } try { $this->validCountry($request->input('country_code', '')); $address = $this->repository->update($request->all(), $address); return $this->response->item($address, new BaseTransformer()); } catch (\Exception $e) { throw new StoreResourceFailedException($e->getMessage()); } }