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 http://www.yiiframework.com/doc-2.0/guide-security-authorization.html

  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' => 'user.id', 'username' => 'user.username',  'auth_assignment.user_id', 'role' =>  'auth_assignment.item_name' ])

            ->from('user')

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




        $dataProvider = new ActiveDataProvider([

            'query' => $query,

        ]);

doesn’t work =(

It is possible, but with SqlDataProvider.

Or you can create view in db server.

Update:

replace


$query = UserList::find()

with


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