20230523103006_add_reputation_gather_to_portrait_table.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. use app\model\CustomerPortraitField;
  5. use app\model\CustomerPortraitFieldSelect;
  6. class AddReputationGatherToPortraitTable 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. subjection
  28. */
  29. public function change()
  30. {
  31. $fieldmod = new CustomerPortraitField;
  32. $list= CustomerPortraitField::where('keyname','basic_info')->field('id,root_id,name')->select()->toArray();
  33. foreach($list as $p=>$m){
  34. $root_id=$m['root_id'];
  35. $all[]=['name' => '口碑采集', 'type' => 5, 'isedit' => 1, 'isdel' => 1,'root_id'=>$root_id,'pid'=>$m['id'], 'status' => 0, 'keyname' => 'reputation_gather', 'is_status' => 0, 'isedit_type' => 1, 'isadd' => 1, 'is_must' => 1, 'sort' => 55, 'unity' => ''];
  36. $all[]=['name' => '进业主群', 'type' => 5, 'isedit' => 1, 'isdel' => 1, 'root_id'=>$root_id,'pid'=>$m['id'], 'status' => 0, 'keyname' => 'into_owner_group', 'is_status' => 0, 'isedit_type' => 1, 'isadd' => 1, 'is_must' => 1, 'sort' => 56, 'unity' => ''];
  37. }
  38. $fieldmod->saveAll($all);
  39. }
  40. }