models/CategorySearch.php
/**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
Creates data provider instance with search query applied
@param array $params


Creates data provider instance with search query applied @param array $params
public function search($params)
    {
        $return = array();
        $query = Category::find();
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);
        $this->load($params);
        if (!$this->validate()) {
            return $dataProvider;
        }
        $result = $query -> all();
        foreach ($result as $value) { 
            $return[$value->parent_id][] = $value;
        }
        $this -> _category_arr = $return;
    }
public function search ( $ params ) { $ return = array ( ) ; $ query = Category :: find ( ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , ] ) ; $ this -> load ( $ params ) ; if ( ! $ this -> validate ( ) ) { return $ dataProvider ; } $ result = $ query -> all ( ) ; foreach ( $ result as $ value ) { $ return [ $ value -> parent_id ] [ ] = $ value ; } $ this -> _category_arr = $ return ; }
Creates data provider instance with search query applied
 @param array $params
Creates data provider instance with search query applied @param array $params
// add conditions that should always apply here // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); //Читаем все строчки и записываем в переменную $result //Обходим массив