20220714063751_change_menus20220714.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. use app\model\Permission;
  3. use think\migration\Migrator;
  4. use think\migration\db\Column;
  5. class ChangeMenus20220714 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. $sucai = Permission::where(['auth_name' => '素材中心'])->find();
  31. $childs = Permission::where(['pid' => $sucai->id])->select();
  32. $change = [
  33. 'material/caselisting' => ['auth_name' => '装修案例', 'sort' => 30],
  34. 'material/evidencelisting' => ['auth_name' => '客户好评', 'sort' => 36],
  35. 'video/index' => ['auth_name' => '拓客视频', 'sort' => 32],
  36. 'article/index' => ['auth_name' => '拓客图文', 'sort' => 34],
  37. 'construction/index' => ['auth_name' => '在施工地', 'sort' => 40],
  38. 'building/index' => ['auth_name' => '热装楼盘', 'sort' => 38]
  39. ];
  40. foreach ($childs as $c) {
  41. $c->save($change[$c->uri]);
  42. }
  43. Permission::where(['uri' => 'article/add'])->update(['auth_name'=>'图文管理']);
  44. Permission::where(['uri' => 'article/del'])->update(['auth_name'=>'图文删除']);
  45. Permission::where(['uri' => 'material/evidence_add'])->update(['auth_name'=>'好评管理']);
  46. Permission::where(['uri' => 'material/apievidelete'])->update(['auth_name'=>'好评删除']);
  47. }
  48. }