20230504160632_add_wechat_activity_permission.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. use app\model\Permission;
  5. use app\model\Grant;
  6. class AddWechatActivityPermission extends Migrator
  7. {
  8. /**
  9. * Change Method.
  10. *
  11. * Write your reversible migrations using this method.
  12. *
  13. * More information on writing migrations is available here:
  14. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  15. *
  16. * The following commands can be used in this method and Phinx will
  17. * automatically reverse them when rolling back:
  18. *
  19. * createTable
  20. * renameTable
  21. * addColumn
  22. * renameColumn
  23. * addIndex
  24. * addForeignKey
  25. *
  26. * Remember to call "create()" or "update()" and NOT "save()" when working
  27. * with the Table class.
  28. */
  29. public function change()
  30. {
  31. $pid = (new Permission())->where('auth_name', '=', '公司活动')->value('id');
  32. $data['pid'] = $pid;
  33. $data['auth_name'] = '微爆活动';
  34. $data['uri'] = 'wechatActivity/index';
  35. $data['is_menu'] = 1;
  36. $data['sort'] = 50;
  37. $data['relation'] = 'wechatActivity/index';
  38. $result = Permission::create($data);
  39. (new Permission)->saveAll([
  40. ['pid' => $result->id, 'auth_name' => '微爆添加', 'uri' => 'wechatActivity/add', 'is_menu' => 0, 'sort' => 50, 'relation' => 'wechatActivity/add,wechatActivity/edit'],
  41. ['pid' => $result->id, 'auth_name' => '微爆删除', 'uri' => 'wechatActivity/del', 'is_menu' => 0, 'sort' => 50, 'relation' => 'wechatActivity/del']
  42. ]);
  43. }
  44. }