public function actionFollowing()
 {
     $query = Topic::find()->innerJoinWith('authorFollowedBy')->where([Favorite::tableName() . '.source_id' => Yii::$app->getUser()->id, Favorite::tableName() . '.type' => Favorite::TYPE_USER]);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count(1), 'pageSize' => $this->settings['list_pagesize'], 'pageParam' => 'p']);
     $topics = $query->select([Topic::tableName() . '.id'])->orderBy([Topic::tableName() . '.id' => SORT_DESC])->offset($pages->offset)->with(['topic.author', 'topic.node', 'topic.lastReply'])->limit($pages->limit)->all();
     return $this->render('following', ['topics' => Util::convertModelToArray($topics), 'pages' => $pages]);
 }
Beispiel #2
0
 public function getFavorites()
 {
     return $this->hasMany(Favorite::className(), ['target_id' => 'id'])->onCondition([Favorite::tableName() . '.type' => Favorite::TYPE_TOPIC]);
 }