20220826034617_update_customer_menu_orders.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. use app\model\Permission;
  5. class UpdateCustomerMenuOrders 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. $menus = Permission::where([['pid','=',7]])->order('sort asc,id asc')->select();
  31. foreach ($menus as $k => $v) {
  32. Permission::where('id',$v['id'])->update(['sort'=>($k+1)*7]);
  33. }
  34. //客户设置放在店面客户管理下面
  35. $crm = Permission::where([['pid','=',7],['auth_name','=','店面客户管理']])->value('sort');
  36. Permission::where([['pid','=',7],['auth_name','=','客户设置']])->update(['sort'=>$crm+1]);
  37. }
  38. }