/** * Update the specified resource in storage. * * @param int $id * * @return Response * * @apiDefine putUpdate * @apiName update * @apiErrorExample {json} Error-Response: * HTTP/1.1 404 Not Found * {} * * @apiErrorExample {json} Error-Response: * HTTP/1.1 401 Not Authorized * {} * @apiName put * @apiParam {Number} id Model unique ID. **/ public function update($id) { $this->addUserCriteria(); $model = $this->repository->find($id); if (is_null($model)) { return response()->json([], 404); } try { $model = $this->repository->update($model, Input::all()); } catch (ModelNotValid $e) { return response()->json($e->getErrors(), 400); } return response()->json($model, 202); }
/** * @param $id * @param $data * * @dataProvider updateKoProvider * @expectedException \App\Libraries\Acl\Exceptions\ModelNotValid */ public function testUpdateKo($id, $data) { $model = $this->repository->update($this->repository->find($id), $data); $this->assertModel($model, false); }