/** * Lists all Term models. * @return mixed */ public function actionIndex() { // Store the active taxonomy-id in a session var if it is provided through the url if (Yii::$app->request->get('taxonomy-id') != null) { Yii::$app->session->set('taxonomy.taxonomy-id', Yii::$app->request->get('taxonomy-id')); } return $this->render('index', ['tree' => Term::find()->tree(Yii::$app->session->get('taxonomy.taxonomy-id'))]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Term::find()->joinWith('translations')->roots(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['name' => $this->name]); return $dataProvider; }