User's GRID with roles

Hi there!

I’m learning Yii from official documentation.

So now I’m trying to implement user functionality (this first step of my admin panel).

  1. I successful RBAC model => made

  2. I made user table, and all works fine.

  3. I used GII to create CRUD model for User.

I need to show in User GRID their roles. I see that I need to use GRID::widget.

My question:

How can I use GRID::widget with two tables from database (or with two models)?

Maybe I explained too confused.

My question is:

Can I use two or more models in $dataProvider ?

$query = UserList::find()

            ->select( ['id' => '', 'username' => 'user.username',  'auth_assignment.user_id', 'role' =>  'auth_assignment.item_name' ])


            ->leftJoin('auth_assignment', 'auth_assignment.user_id =');

        $dataProvider = new ActiveDataProvider([

            'query' => $query,


doesn’t work =(

It is possible, but with SqlDataProvider.

Or you can create view in db server.



$query = UserList::find()


$query = (new yii\db\Query())