/** * Lists all Comment models. * @return mixed */ public function actionIndex() { Yii::$app->user->setReturnUrl(\yii\helpers\Url::to()); $searchModel = new CommentSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }
/** * 文章页面 * @param $slug * @return string */ public function actionView($slug) { $model = Post::getPostBySlug($slug); $commentSearch = new CommentSearch(); if (!$model) { } $dataProvider = $commentSearch->search(['post_id' => $model->id]); return $this->render('view', ['model' => $model, 'dataProvider' => $dataProvider]); }
/** * 我的评论 * @return string */ public function actionComments() { $currentUser = \Yii::$app->user->identity; $params = \Yii::$app->request->queryParams; if (!$currentUser) { $this->goHome(); } $params['CommentSearch']['user_id'] = $currentUser->id; $commentSearch = new CommentSearch(); $dataProvider = $commentSearch->search($params); return $this->render('comments', ['dataProvider' => $dataProvider]); }
/** * Lists all Comment models. * @return mixed */ public function actionIndex() { $searchModel = new CommentSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }