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]]); }
public function afterDelete() { parent::afterDelete(); $xs = \common\components\search\xunSearch\Feed::findOne($this->id); $xs->delete(); }
public function actionView($id, $page = 1, $all = 1) { error_reporting(1); $model = $this->findModel($id); $defaultPageSize = 20; $offset = ($page - 1) * $defaultPageSize; if (!$all) { $queryWord = [$model->name]; } else { $children = $model->children()->indexBy('id')->asArray()->all(); $childrenValues = ArrayHelper::merge([$model->id => $model->name], ArrayHelper::getColumn($children, 'name')); $queryWord = ArrayHelper::merge(["OR"], $childrenValues); } $query = Feed::find(); $condition = $queryWord; $query->where($condition); // $condition = ['obj_type'=>App::OBJ_TYPE_FEED]; // $query->andwhere($condition); $query->offset($offset)->limit($defaultPageSize)->orderBy("id desc"); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $defaultPageSize]]); $feeds = $dataProvider->getModels(); $totalCount = $dataProvider->getTotalCount(); $pages = new Pagination(['totalCount' => $totalCount, 'defaultPageSize' => $defaultPageSize]); return $this->render("view", ['model' => $model, 'feeds' => $feeds, 'pages' => $pages]); }