/** * @return Response */ public function actionTagSuggest() { $response = ['data' => ['status' => false], 'format' => 'json']; if (isset($_GET['q']) && ($keyword = trim($_GET['q'])) !== '') { $response['data']['items'] = Tag::suggest($keyword); } return new Response($response); }
/** * @param $tags * @return string */ public function run($tags) { $tags = Tag::string2Array($tags); /** @var QuestionSearch $searchModel */ $searchModel = $this->getModel(); $dataProvider = $searchModel->search(['tags' => $tags]); $models = $dataProvider->getModels(); return $this->render(compact('searchModel', 'models', 'dataProvider', 'tags')); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Tag::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'frequency' => $this->frequency]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * Finds the Tag model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Tag the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Tag::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return array a list of links that point to the post list filtered by every tag of this post */ public function getTagsList() { return Tag::string2Array($this->tags); }
public function down() { $this->dropTable(Tag::tableName()); }
/** * @inheritdoc */ public function run() { $models = Tag::find()->orderBy('frequency')->limit($this->limit)->all(); return $this->render('tags', ['models' => $models]); }