/** * Process PUT Requests. Updates an existing address. * * @param request Request to execute. * * @return Response Response to send. */ public function put(Request $request) { $a = Address::fromArray($request->getBody()); // TODO: improve error handling if ($this->addressService->updateAddress($a)) { return Response::ok(); } return Response::notFound(); }
/** * Process POST Requests, which appends a new address to the collection. * * @param request Request to execute. * * @return Response Response to send. */ public function post(Request $request) { $a = Address::fromArray($request->getBody()); // TODO: improve error handling $id = $this->addressService->createAddress($a); if (!is_null($id)) { return Response::created("{$id}"); } else { return Response::badRequest(); } }