/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $objs = factory(Entity::class, 30)->make();
     Entity::truncate();
     foreach ($objs as $var) {
         Entity::create($var->toArray());
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $entity = Entity::find($id);
     if (!$entity) {
         return response()->json(['errors' => array(['code' => 404, 'message' => 'No se encuentra una entidad con ese c�digo.'])], 404);
     }
     return response()->json(['status' => 'ok', 'data' => $entity], 200);
 }
 public function search($params)
 {
     $query = Entity::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created' => $this->created, 'modified' => $this->modified]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
 /**
  * Finds the Entity model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Entity the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Entity::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }