bighoc
(Samusenkoiv)
1
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).
-
I successful RBAC model => made http://www.yiiframework.com/doc-2.0/guide-security-authorization.html
-
I made user table, and all works fine.
-
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)?
bighoc
(Samusenkoiv)
2
Maybe I explained too confused.
My question is:
Can I use two or more models in $dataProvider ?
bighoc
(Samusenkoiv)
3
$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 =(
Pasman
(Pasman P)
4
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())