/** * @test update */ public function testUpdateTelefone() { $telefone = $this->makeTelefone(); $fakeTelefone = $this->fakeTelefoneData(); $updatedTelefone = $this->telefoneRepo->update($fakeTelefone, $telefone->id); $this->assertModelData($fakeTelefone, $updatedTelefone->toArray()); $dbTelefone = $this->telefoneRepo->find($telefone->id); $this->assertModelData($fakeTelefone, $dbTelefone->toArray()); }
/** * @param int $id * @param UpdateTelefoneAPIRequest $request * @return Response * * @SWG\Put( * path="/telefones/{id}", * summary="Update the specified Telefone in storage", * tags={"Telefone"}, * description="Update Telefone", * produces={"application/json"}, * @SWG\Parameter( * name="id", * description="id of Telefone", * type="integer", * required=true, * in="path" * ), * @SWG\Parameter( * name="body", * in="body", * description="Telefone that should be updated", * required=false, * @SWG\Schema(ref="#/definitions/Telefone") * ), * @SWG\Response( * response=200, * description="successful operation", * @SWG\Schema( * type="object", * @SWG\Property( * property="success", * type="boolean" * ), * @SWG\Property( * property="data", * ref="#/definitions/Telefone" * ), * @SWG\Property( * property="message", * type="string" * ) * ) * ) * ) */ public function update($id, UpdateTelefoneAPIRequest $request) { $input = $request->all(); /** @var Telefone $telefone */ $telefone = $this->telefoneRepository->find($id); if (empty($telefone)) { return Response::json(ResponseUtil::makeError('Telefone not found'), 404); } $telefone = $this->telefoneRepository->update($input, $id); return $this->sendResponse($telefone->toArray(), 'Telefone updated successfully'); }