20220714103120_change_menus20220715.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. use app\model\Permission;
  3. use think\migration\Migrator;
  4. use think\migration\db\Column;
  5. class ChangeMenus20220715 extends Migrator
  6. {
  7. /**
  8. * Change Method.
  9. *
  10. * Write your reversible migrations using this method.
  11. *
  12. * More information on writing migrations is available here:
  13. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  14. *
  15. * The following commands can be used in this method and Phinx will
  16. * automatically reverse them when rolling back:
  17. *
  18. * createTable
  19. * renameTable
  20. * addColumn
  21. * renameColumn
  22. * addIndex
  23. * addForeignKey
  24. *
  25. * Remember to call "create()" or "update()" and NOT "save()" when working
  26. * with the Table class.
  27. */
  28. public function change()
  29. {
  30. $company = Permission::where(['auth_name' => '企业管理'])->find();
  31. $oa = Permission::where(['auth_name' => 'OA办公'])->find();
  32. $dailyWork = Permission::where(['uri' => 'dailyWork/work'])->find();
  33. $oa->relation = $dailyWork->relation;
  34. $oa->uri = $dailyWork->uri;
  35. $oa->pid = $company->id;
  36. // 排序
  37. $msg = Permission::where(['uri' => 'msg/index'])->find();
  38. $org = Permission::where(['uri' => 'org/reward_rule'])->find();
  39. $oa->sort = $msg->sort + 1;
  40. $org->sort = $msg->sort + 2;
  41. $org->auth_name = '激励规则';
  42. $org->save();
  43. $oa->save();
  44. $dailyWork->delete();
  45. $wechat = Permission::where(['auth_name' => '企微管理'])->find();
  46. $wechat->auth_name = '企业微信';
  47. $wechat->save();
  48. }
  49. }