Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function studentSearch($params)
 {
     $courseIds = \app\components\OvcCourse::getUserCourseIds();
     $userIds = \app\components\OvcUser::getUserIdsByCourseIds($courseIds);
     $query = User::find()->joinWith('role')->where(['user.id' => $userIds, 'user.role_id' => \app\components\OvcRole::STUDENT]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->params['pageSize']]]);
     $this->load($params);
     /**
      * sortin related columns
      */
     $dataProvider->sort->attributes['roleName'] = ['asc' => ['role.name' => SORT_ASC], 'desc' => ['role.name' => SORT_DESC]];
     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(['user.id' => $this->id, 'user.active' => $this->active, 'user.role_id' => $this->role_id, 'user.created_at' => $this->created_at, 'user.modified_at' => $this->modified_at]);
     $query->andFilterWhere(['like', 'user.first_name', $this->first_name])->andFilterWhere(['like', 'user.last_name', $this->last_name])->andFilterWhere(['like', 'user.username', $this->username])->andFilterWhere(['like', 'user.password', $this->password])->andFilterWhere(['like', 'user.email', $this->email])->andFilterWhere(['like', 'user.auth_key', $this->auth_key])->andFilterWhere(['like', 'user.access_token', $this->access_token])->andFilterWhere(['like', 'role.name', $this->roleName]);
     return $dataProvider;
 }
Example #2
0
 public function actionIndex()
 {
     $courseIds = \app\components\OvcCourse::getUserCourseIds();
     $msg = \app\components\OvcUser::getUserIdsByCourseIds($courseIds);
     return $this->render('index', ['msg' => $msg]);
 }