AuthCreateController.php 967 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace console\controllers;
  3. use yii\console\Controller;
  4. use common\models\rbac\AuthItemChild;
  5. use common\models\rbac\AuthRole;
  6. /**
  7. * Class AuthCreateController
  8. *
  9. * php ./yii auth-create/index
  10. *
  11. * @package addons\Merchants\console\controllers
  12. */
  13. class AuthCreateController extends Controller
  14. {
  15. public $data = [
  16. [
  17. 'item_id' => 0,
  18. 'name' => '/merchants/archives/*',
  19. 'app_id' => 'merchant',
  20. 'is_addon' => 1,
  21. 'addon_name' => 'Merchants',
  22. ],
  23. ];
  24. /**
  25. * 添加权限
  26. */
  27. public function actionIndex()
  28. {
  29. $role = AuthRole::find()->select('id')->asArray()->all();
  30. foreach ($role as $item) {
  31. foreach ($this->data as $datum) {
  32. $model = new AuthItemChild();
  33. $model->attributes = $datum;
  34. $model->role_id = $item['id'];
  35. $model->save();
  36. }
  37. }
  38. }
  39. }
粤ICP备19079148号