Exemple #1
0
 public function prepareDataProvider()
 {
     $followTagByUid = Tag::getFollowTagsByUid(\Yii::$app->user->id);
     if (!$followTagByUid) {
         return null;
     }
     $tags = ArrayHelper::getColumn($followTagByUid, 'name');
     $query = \common\components\search\xunSearch\Feed::find();
     $condition = ArrayHelper::merge(["or"], $tags);
     $query->where($condition);
     $condition = ['obj_type' => App::OBJ_TYPE_FEED];
     $query->andwhere($condition);
     $query->with("author");
     return new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 20]]);
 }
Exemple #2
0
 function actionIndex()
 {
     $roots = Tag::find()->roots()->all();
     $hots = Tag::find()->limit(20)->orderBy("rand()")->all();
     if (!Yii::$app->user->isGuest) {
         $my = Tag::getFollowTagsByUid(Yii::$app->user->id, false);
     } else {
         $my = null;
     }
     return $this->render("index", ['roots' => $roots, 'hots' => $hots, 'my' => $my]);
 }