findCommentList() public static method

评论列表
public static findCommentList ( $postId ) : static
$postId
return static
Beispiel #1
0
 /**
  * 话题详细页
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = Topic::findTopic($id);
     $dataProvider = new ActiveDataProvider(['query' => PostComment::findCommentList($id), 'pagination' => ['pageSize' => self::PAGE_SIZE]]);
     // 文章浏览次数
     Topic::updateAllCounters(['view_count' => 1], ['id' => $id]);
     $user = Yii::$app->user->identity;
     $admin = $user && ($user->isAdmin($user->username) || $user->isSuperAdmin($user->username)) ? true : false;
     return $this->render('view', ['model' => $model, 'dataProvider' => $dataProvider, 'comment' => new PostComment(), 'admin' => $admin]);
 }
Beispiel #2
0
 /**
  * 话题详细页
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = Topic::findTopic($id);
     //登录才能访问的节点内容
     if (\Yii::$app->user->isGuest && in_array($model->category->alias, params('loginNode'))) {
         $this->flash('查看本主题需要登录!', 'warning');
         return $this->redirect(['/site/login']);
     }
     $dataProvider = new ActiveDataProvider(['query' => PostComment::findCommentList($id), 'pagination' => ['pageSize' => self::PAGE_SIZE], 'sort' => ['defaultOrder' => ['created_at' => SORT_ASC]]]);
     // 文章浏览次数
     Topic::updateAllCounters(['view_count' => 1], ['id' => $id]);
     //内容页面打赏
     if (in_array($model->category->alias, params('donateNode')) || array_intersect(explode(',', $model->tags), params('donateTag'))) {
         $donate = Donate::findOne(['user_id' => $model->user_id, 'status' => Donate::STATUS_ACTIVE]);
     }
     /** @var User $user */
     $user = Yii::$app->user->identity;
     $admin = $user && ($user->isAdmin($user->username) || $user->isSuperAdmin($user->username)) ? true : false;
     return $this->render('view', ['model' => $model, 'dataProvider' => $dataProvider, 'comment' => new PostComment(), 'admin' => $admin, 'donate' => isset($donate) ? $donate : []]);
 }