public function search($params)
 {
     $query = Thread::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $this->addCondition($query, 'id');
     $this->addCondition($query, 'title', true);
     $this->addCondition($query, 'body', true);
     $this->addCondition($query, 'created_at');
     $this->addCondition($query, 'created_by');
     $this->addCondition($query, 'updated_at');
     $this->addCondition($query, 'updated_by');
     $this->addCondition($query, 'blog_id');
     $this->addCondition($query, 'root');
     $this->addCondition($query, 'lft');
     $this->addCondition($query, 'rgt');
     $this->addCondition($query, 'level');
     return $dataProvider;
 }
<?php

use yii\helpers\Html;
use besnovatyj\blog\models\Thread;
use kartik\tree\TreeView;
$this->title = Yii::t('thread', 'Threads');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="thread-index">

    <h4><?php 
echo Html::encode($this->title);
?>
</h4>
    <?php 
echo TreeView::widget(['query' => Thread::find()->addOrderBy('root, lft'), 'headingOptions' => ['label' => 'Threads'], 'isAdmin' => false, 'displayValue' => 1]);
?>
</div>


?>
<div class="thread-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a(Yii::t('blog', 'Create {modelClass}', ['modelClass' => 'Thread']), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'title', 'value' => function ($data) {
    return str_repeat('--', $data->depth - 1) . ' ' . $data->title;
}], 'body:ntext', 'created_at:datetime', 'created_by', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>

<h3>Roots</h3>
<?php 
foreach (Thread::find()->roots()->all() as $item) {
    echo $item->title;
}