public function getTerms($object_id, $name = []) { $query = TaxonomyTerms::find()->select(TaxonomyTerms::tableName() . '.term')->where("taxonomy_id = {$this->id}")->andFilterWhere(['taxonomy_terms.term' => $name]); if ($object_id) { $query->innerJoin($this->table, $this->table . '.term_id = taxonomy_terms.id')->onCondition("{$this->table}.object_id = {$object_id}"); } return ArrayHelper::getColumn($query->all(), 'term'); }
/** * Displays a single TaxonomyDef model. * @param integer $id * @return mixed */ public function actionView($id) { $termProvider = new ActiveDataProvider(['query' => TaxonomyTerms::find()->andFilterWhere(['taxonomy_id' => $id]), 'sort' => ['defaultOrder' => ['total_count' => SORT_DESC]]]); return $this->render('view', ['model' => $this->findModel($id), 'termProvider' => $termProvider]); }
/** * @param integer $termId * @return boolean */ public function hasChildren($termId) { return TaxonomyTerms::find()->where("parent_id = {$termId}")->exists(self::getDb()); }
public function listTerms() { $terms = TaxonomyTerms::find()->select('term')->where(['taxonomy_id' => $this->id])->asArray()->all(); return ArrayHelper::getColumn($terms, 'term'); }