Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Comstock::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pagesize' => 10]]);
     if (isset($_GET['ComstockSearch']) && !($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     /*
      $this->load($params);
     
      if (!$this->validate()) {
      // uncomment the following line if you do not want to any records when validation fails
      // $query->where('0=1');
      return $dataProvider;
      }
     * 
     */
     $query->andFilterWhere(['id' => $this->id, 'eqmType' => $this->eqmType, 'status' => $this->status, 'addToSystem' => $this->addToSystem, 'warranty' => $this->warranty, 'dealer' => $this->dealer, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'cat' => $this->cat, 'location' => $this->location]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'brand', $this->brand])->andFilterWhere(['like', 'model', $this->model])->andFilterWhere(['like', 'price', $this->price])->andFilterWhere(['like', 'serial', $this->serial])->andFilterWhere(['like', 'images', $this->images])->andFilterWhere(['like', 'eqmnum', $this->eqmnum])->andFilterWhere(['like', 'desc', $this->desc])->andFilterWhere(['like', 'amount', $this->amount])->andFilterWhere(['like', 'budget', $this->budget])->andFilterWhere(['like', 'howtobuy', $this->howtobuy])->andFilterWhere(['like', 'invnum', $this->invnum]);
     return $dataProvider;
 }