/** * @test update */ public function testUpdateAjuda() { $ajuda = $this->makeAjuda(); $fakeAjuda = $this->fakeAjudaData(); $updatedAjuda = $this->ajudaRepo->update($fakeAjuda, $ajuda->id); $this->assertModelData($fakeAjuda, $updatedAjuda->toArray()); $dbAjuda = $this->ajudaRepo->find($ajuda->id); $this->assertModelData($fakeAjuda, $dbAjuda->toArray()); }
/** * @param int $id * @param UpdateAjudaAPIRequest $request * @return Response * * @SWG\Put( * path="/ajudas/{id}", * summary="Update the specified Ajuda in storage", * tags={"Ajuda"}, * description="Update Ajuda", * produces={"application/json"}, * @SWG\Parameter( * name="id", * description="id of Ajuda", * type="integer", * required=true, * in="path" * ), * @SWG\Parameter( * name="body", * in="body", * description="Ajuda that should be updated", * required=false, * @SWG\Schema(ref="#/definitions/Ajuda") * ), * @SWG\Response( * response=200, * description="successful operation", * @SWG\Schema( * type="object", * @SWG\Property( * property="success", * type="boolean" * ), * @SWG\Property( * property="data", * ref="#/definitions/Ajuda" * ), * @SWG\Property( * property="message", * type="string" * ) * ) * ) * ) */ public function update($id, UpdateAjudaAPIRequest $request) { $input = $request->all(); /** @var Ajuda $ajuda */ $ajuda = $this->ajudaRepository->find($id); if (empty($ajuda)) { return Response::json(ResponseUtil::makeError('Ajuda not found'), 404); } $ajuda = $this->ajudaRepository->update($input, $id); return $this->sendResponse($ajuda->toArray(), 'Ajuda updated successfully'); }
/** * Update the specified Ajuda in storage. * * @param int $id * @param UpdateAjudaRequest $request * * @return Response */ public function update($id, UpdateAjudaRequest $request) { $ajuda = $this->ajudaRepository->findWithoutFail($id); if (empty($ajuda)) { Flash::error('Ajuda not found'); return redirect(route('ajudas.index')); } $ajuda = $this->ajudaRepository->update($request->all(), $id); Flash::success('Ajuda updated successfully.'); return redirect(route('ajudas.index')); }