/** * Lists all Activity models. * @return mixed */ public function actionIndex() { $schedule = Activity::getAllActivities(); $searchModel = new ActivitySearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); /*$dataProvider = new ActiveDataProvider([ 'query' => Activity::find(), ]);*/ return $this->render('index', ['dataProvider' => $dataProvider, 'schedule' => $schedule, 'searchModel' => $searchModel]); }
/** * Lists all Activity models. * @return mixed */ public function actionIndex($id = null) { //Check user level & existence of $id $user = Yii::$app->user->identity->level == 0 && $id != null ? User::findOne($id) : Yii::$app->user->identity; $searchModel = new ActivitySearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $parentIds = \yii\helpers\ArrayHelper::getColumn($user->findParents()->all(), 'id'); $query = Activity::find()->where(['in', 'user_id', $parentIds])->orderBy(['id' => SORT_DESC]); //Activity::find()->where('user_id = :parent_id OR user_id = :id', [':parent_id' => $user->id, ':id'=> $user->parent->id ])->orderBy(['id' => SORT_DESC]); //var_dump($user); die(); $activityProvider = new ActiveDataProvider(['query' => $user->level == 3 ? $query : $query->orWhere('user_id = :parent_id OR user_id = :id', [':parent_id' => $user->id, ':id' => $user->parent->id]), 'pagination' => ['pageSize' => 8]]); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'activityProvider' => $activityProvider, 'user' => $user]); }
/** * Lists all Activity models. * @return mixed */ public function actionIndex() { $searchModel = new ActivitySearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }