/** * Lists all Post models on specific post type. * If there is user, the action will generate list of all Post models based on user. * * @param integer $post_type * @param null|string $user * * @throws \yii\web\ForbiddenHttpException * @throws \yii\web\NotFoundHttpException * @return mixed */ public function actionIndex($post_type, $user = null) { $postType = $this->findPostType($post_type); $searchModel = new PostSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams, $post_type, $user); if (!Yii::$app->user->can($postType->post_type_permission)) { throw new ForbiddenHttpException(Yii::t('writesdown', 'You are not allowed to perform this action.')); } return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'postType' => $postType, 'user' => $user]); }
/** * Lists all Post models. * @return mixed */ public function actionIndex() { $searchModel = new PostSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }