/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Category::find();
     $query->orderBy('position DESC, title');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'position' => $this->position]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'alias', $this->alias]);
     return $dataProvider;
 }
 /**
  * Displays categories as tree.
  *
  * @return mixed
  */
 public function actionTree()
 {
     $models = Category::find()->orderBy('position DESC, title')->all();
     $model = new Category();
     return $this->render('tree', ['model' => $model, 'models' => $models]);
 }
Example #3
0
 /**
  * Check that blog just installed
  * @return bool
  */
 public static function isJustInstalled()
 {
     $types = Type::find()->all();
     $categories = Category::find()->all();
     return empty($types) || empty($categories) ?: false;
 }