/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Categories::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'parentid' => $this->parentid, 'published' => $this->published, 'access' => $this->access, 'ordering' => $this->ordering]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'image_caption', $this->image_caption])->andFilterWhere(['like', 'image_credits', $this->image_credits])->andFilterWhere(['like', 'params', $this->params])->andFilterWhere(['like', 'metadesc', $this->metadesc])->andFilterWhere(['like', 'metakey', $this->metakey])->andFilterWhere(['like', 'robots', $this->robots])->andFilterWhere(['like', 'author', $this->author])->andFilterWhere(['like', 'copyright', $this->copyright])->andFilterWhere(['like', 'language', $this->language]);
     return $dataProvider;
 }
示例#2
0
 /**
  * Return array for Category Select2
  * @return array
  */
 public function getCategoriesSelect2()
 {
     $categories = Categories::find()->orderBy('name')->all();
     $array[0] = Yii::t('articles', 'No Parent');
     foreach ($categories as $category) {
         $array[$category['id']] = $category['name'];
     }
     return $array;
 }
示例#3
0
 /**
  * Return array for Category Select2
  * @return array
  **/
 public function getCategoriesSelect2()
 {
     $categories = Categories::find()->select(['id', 'name'])->where(['state' => 1])->all();
     $array[0] = Yii::t('articles', 'No Category');
     foreach ($categories as $category) {
         $array[$category['id']] = $category['name'];
     }
     return $array;
 }