示例#1
0
 /**
  * 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);
 }
示例#2
0
 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;
 }