/**
  * Creates data provider instance with search query applied
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     if (empty($params['status'])) {
         $this->status = '';
     }
     /** @var Query $query */
     $query = Group::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['name' => SORT_ASC]], 'pagination' => ['pageSize' => Yii::$app->params['pagination']['pageSize']]]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['status' => $this->status]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Beispiel #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGroup()
 {
     return $this->hasOne(Group::className(), ['id' => 'group_id']);
 }