Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Promotion::find()->where(['status' => [Promotion::NOT_MODERATED]]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]], 'pagination' => ['pageSize' => 20]]);
     $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, 'user_id' => $this->user_id, 'page_id' => $this->page_id, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'url', $this->url]);
     return $dataProvider;
 }
Esempio n. 2
0
 public function actionViewAll()
 {
     $userId = \Yii::$app->user->getId();
     $provider = new ActiveDataProvider(['query' => Promotion::find()->where(['user_id' => $userId]), 'sort' => ['defaultOrder' => ['id' => SORT_DESC]], 'pagination' => ['pageSize' => 20]]);
     return $this->render('index', ['provider' => $provider]);
 }