コード例 #1
0
ファイル: RepositoryTest.php プロジェクト: ndrx-io/elude
 /**
  * @param $attributes
  *
  * @dataProvider createKoProvider
  * @expectedException \App\Libraries\Acl\Exceptions\ModelNotValid
  *
  */
 public function testCreateKo($attributes)
 {
     $class = $this->repository->getModelClass();
     $model = $this->repository->create(new $class($attributes));
     if ($model instanceof ValidationInterface && $model->getErrors() !== null) {
         $this->assertGreaterThan(0, $model->getErrors()->count());
     }
     $this->assertModel($model, false);
 }
コード例 #2
0
ファイル: ResourcesController.php プロジェクト: ndrx-io/elude
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  *
  * @apiDefine postStore
  * @apiName store
  * @apiErrorExample {json} Error-Response:
  *     HTTP/1.1 404 Not Found
  *     {}
  *
  * @apiErrorExample {json} Error-Response:
  *     HTTP/1.1 401 Not Authorized
  *     {}
  *
  * @apiErrorExample {json} Error-Response:
  *     HTTP/1.1 400 Bad Request
  *     {
  *            'errors' : []
  *     }
  * @apiName show
  */
 public function store()
 {
     try {
         $class = $this->repository->getModelClass();
         $model = new $class(Input::all());
         if ($model instanceof UserRestrictionInterface) {
             $model->user()->associate(\Auth::user());
         }
         $model = $this->repository->create($model);
     } catch (ModelNotValid $e) {
         return response()->json($e->getErrors(), 400);
     }
     return response()->json($model, 201);
 }