示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Building::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'cost_iron' => $this->cost_iron, 'cost_steel' => $this->cost_steel, 'cost_chemicals' => $this->cost_chemicals, 'cost_vv4a' => $this->cost_vv4a, 'cost_ice' => $this->cost_ice, 'cost_water' => $this->cost_water, 'cost_energy' => $this->cost_energy, 'cost_people' => $this->cost_people, 'cost_credits' => $this->cost_credits, 'cost_time' => $this->cost_time, 'balance_iron' => $this->balance_iron, 'balance_steel' => $this->balance_steel, 'balance_chemicals' => $this->balance_chemicals, 'balance_vv4a' => $this->balance_vv4a, 'balance_ice' => $this->balance_ice, 'balance_water' => $this->balance_water, 'balance_energy' => $this->balance_energy, 'balance_people' => $this->balance_people, 'balance_credits' => $this->balance_credits, 'balance_satisfaction' => $this->balance_satisfaction, 'storage_chemicals' => $this->storage_chemicals, 'storage_ice_and_water' => $this->storage_ice_and_water, 'storage_energy' => $this->storage_energy, 'shelter_iron' => $this->shelter_iron, 'shelter_steel' => $this->shelter_steel, 'shelter_chemicals' => $this->shelter_chemicals, 'shelter_vv4a' => $this->shelter_vv4a, 'shelter_ice_and_water' => $this->shelter_ice_and_water, 'shelter_energy' => $this->shelter_energy, 'shelter_people' => $this->shelter_people, 'highscore_points' => $this->highscore_points, 'modified' => $this->modified, 'limit' => $this->limit]);
     $query->andFilterWhere(['like', 'group', $this->group])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
示例#2
0
 public function search($params)
 {
     $query = Building::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]], 'pagination' => ['pageSize' => 20]]);
     // load the seach form data and validate
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $dateBegin = strtotime($this->date);
     $dateEnd = $dateBegin + 86400;
     // adjust the query by adding the filters
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['school_id' => $this->school_id])->andFilterWhere(['status' => $this->status])->andFilterWhere(['>=', 'created_at', $this->date ? $dateBegin : null])->andFilterWhere(['<', 'created_at', $this->date ? $dateEnd : null]);
     return $dataProvider;
 }