Beispiel #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Sport::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'picture', $this->picture])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
 /**
  * Affiche le formulaire pour éditer la ressource.
  *
  * @param  int  $id l'id du sport à éditer 
  * @return Response
  */
 public function edit($id)
 {
     try {
         $sport = Sport::findOrFail($id);
         $terrainSports = Sport::find($id)->terrains;
         //FIXME: on a déjà le sport
         $terrains = Terrain::all();
         return View::make('sports.edit', compact('sport', 'terrainSports', 'terrains'));
     } catch (Exception $e) {
         App::abort(404);
     }
 }