/** * 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; }
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']); }
public function getTags() { return $this->hasMany(Tag::className(), ['id' => 'tag_id'])->viaTable('tbl_tour_tag_assn', ['tour_id' => 'id']); }
/** * 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.'); } }
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); }
/** * (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; }
/** * @return \yii\db\ActiveQuery */ public function getTags() { return $this->hasMany(Tag::className(), ['TagId' => 'TagId'])->viaTable('documenttag', ['DocumentId' => 'DocumentId']); }
/** * @return \yii\db\ActiveQuery */ public function getTag() { return $this->hasOne(Tag::className(), ['id' => 'tag_id']); }
/** * ($this) getTags : * @return \yii\db\ActiveQuery */ public function getTags() { return $this->hasMany(Tag::className(), ['id' => 'tag_id'])->viaTable('{{%helpdoc_tag}}', ['helpdoc_id' => 'id']); }