/** * @test update */ public function testUpdateEndereco() { $endereco = $this->makeEndereco(); $fakeEndereco = $this->fakeEnderecoData(); $updatedEndereco = $this->enderecoRepo->update($fakeEndereco, $endereco->id); $this->assertModelData($fakeEndereco, $updatedEndereco->toArray()); $dbEndereco = $this->enderecoRepo->find($endereco->id); $this->assertModelData($fakeEndereco, $dbEndereco->toArray()); }
/** * @param int $id * @param UpdateEnderecoAPIRequest $request * @return Response * * @SWG\Put( * path="/enderecos/{id}", * summary="Update the specified Endereco in storage", * tags={"Endereco"}, * description="Update Endereco", * produces={"application/json"}, * @SWG\Parameter( * name="id", * description="id of Endereco", * type="integer", * required=true, * in="path" * ), * @SWG\Parameter( * name="body", * in="body", * description="Endereco that should be updated", * required=false, * @SWG\Schema(ref="#/definitions/Endereco") * ), * @SWG\Response( * response=200, * description="successful operation", * @SWG\Schema( * type="object", * @SWG\Property( * property="success", * type="boolean" * ), * @SWG\Property( * property="data", * ref="#/definitions/Endereco" * ), * @SWG\Property( * property="message", * type="string" * ) * ) * ) * ) */ public function update($id, UpdateEnderecoAPIRequest $request) { $input = $request->all(); /** @var Endereco $endereco */ $endereco = $this->enderecoRepository->find($id); if (empty($endereco)) { return Response::json(ResponseUtil::makeError('Endereco not found'), 404); } $endereco = $this->enderecoRepository->update($input, $id); return $this->sendResponse($endereco->toArray(), 'Endereco updated successfully'); }