Exemple #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Income::find()->with('node');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['time' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'node_id' => $this->node_id, 'type_id' => $this->type_id, 'time' => $this->time]);
     $query->andFilterWhere(['like', 'user_name', isset($params['user']) ? $params['user'] : $this->user_name]);
     return $dataProvider;
 }
 public function actionIndex()
 {
     $searchModel = new IncomeSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel]);
 }