Esempio n. 1
0
 /**
  * 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]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Esempio n. 2
0
 public function removeTags($tags)
 {
     if (empty($tags)) {
         return;
     }
     $updateTag = Tag::findOne(['name' => $tags]);
     foreach ($tags as $name) {
         $updateTag = Tag::findOne(['name' => $name]);
         if (!empty($updateTag)) {
             $updateTag->updateCounters(['frequency' => -1]);
         }
     }
     Tag::deleteAll(['frequency' => '<=0']);
 }
Esempio n. 3
0
 public function getTags()
 {
     return $this->hasMany(Tag::className(), ['id' => 'tag_id'])->viaTable('tbl_tour_tag_assn', ['tour_id' => 'id']);
 }
Esempio n. 4
0
 /**
  * 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.');
     }
 }
Esempio n. 5
0
 public function afterSave($insert, $changedAttributes)
 {
     //        print_r(strtolower($this->tag));die;
     $tag = new Tag();
     $tag->updateFrequency(strtolower($this->_oldTag), strtolower($this->tag));
     parent::afterSave($insert, $changedAttributes);
 }
Esempio n. 6
0
 /**
  * (array) actionList :
  * @param $query
  * @return array
  */
 public function actionList($query)
 {
     $models = Tag::findAllByName($query);
     $items = [];
     foreach ($models as $model) {
         $items[] = ['name' => $model->name];
     }
     // We know we can use ContentNegotiator filter
     // this way is easier to show you here :)
     Yii::$app->response->format = Response::FORMAT_JSON;
     return $items;
 }
Esempio n. 7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTags()
 {
     return $this->hasMany(Tag::className(), ['TagId' => 'TagId'])->viaTable('documenttag', ['DocumentId' => 'DocumentId']);
 }
Esempio n. 8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTag()
 {
     return $this->hasOne(Tag::className(), ['id' => 'tag_id']);
 }
Esempio n. 9
0
 /**
  * ($this) getTags :
  * @return \yii\db\ActiveQuery
  */
 public function getTags()
 {
     return $this->hasMany(Tag::className(), ['id' => 'tag_id'])->viaTable('{{%helpdoc_tag}}', ['helpdoc_id' => 'id']);
 }