How to create permission in yii2-rbac


(soyo20) #1

I am newer for yii and rbac. I installed dektrium/yii2-user and yii2-rbac. but I can’t to create permission and role…I didn’t know the meaning of “children”. How to create a children?
I had create one rule from the webpage


(Alexander Makarov) #2

That is not extension specific:

https://www.yiiframework.com/doc/guide/2.0/en/security-authorization#rbac


(Eloy Gonzalez) #3

Hi @soyo20;

Try using this code, example:

<?php 
      CONST ROLE_PARENT = 'ROOT';
      CONST ROLE_CHILD = 'ADMIN'; 
      $authManager = new Yii::$app->authManager();
      $authManager->addChild(ROLE_PARENT, ROLE_CHILD);
?>

This insert a row into auth_item_child tabl