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 $id * * @return \Symfony\Component\HttpFoundation\Response */ public function delete($id) { try { $address = $this->repository->findBy('_id', $id); if (!$address) { throw new DeleteResourceFailedException('Register not found'); } $address->delete(); return $this->response->noContent(); } catch (\Exception $e) { throw new DeleteResourceFailedException($e->getMessage()); } }