20221112102003_update_data_to_customer_portrait_field.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. use app\model\CustomerPortraitField;
  5. class UpdateDataToCustomerPortraitField 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. $field = CustomerPortraitField::where([['keyname','=','group_building']])->select()->toArray();
  31. $save = [];
  32. foreach ($field as $v) {
  33. $save[] = [
  34. 'name' => '建群时间',
  35. 'pid' => $v['pid'],
  36. 'type' => 5,
  37. 'isedit' => 1,
  38. 'isdel' => 1,
  39. 'root_id' => $v['root_id'],
  40. 'status' => $v['status'],
  41. 'keyname' => 'group_building_date',
  42. 'is_status' => 0,
  43. 'isedit_type' => 1,
  44. 'sort' => $v['sort']+1,
  45. 'isadd' => $v['isadd'],
  46. 'is_must' => 1
  47. ];
  48. }
  49. if($save) CustomerPortraitField::insertAll($save);
  50. }
  51. }