Пример #1
0
 /**
  * @return string
  */
 public function actionTag()
 {
     if (Yii::$app->getRequest()->getIsAjax()) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         $query = Yii::$app->getRequest()->get('query');
         if ($query != null) {
             $rows = Tag::find()->where(['like', 'name', $query])->limit(5)->asArray()->all();
             $tags = array_unique(ArrayHelper::getColumn($rows, 'name'));
             $tags = array_values($tags);
             return $tags;
         }
     }
     throw new NotFoundHttpException();
 }