1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- use think\migration\Migrator;
- use think\migration\db\Column;
- use app\model\SmartScreen;
- use app\model\SmartScreenCate;
- use app\model\Company;
- class UpdateSmartScreenDefaultData3 extends Migrator
- {
- /**
- * Change Method.
- *
- * Write your reversible migrations using this method.
- *
- * More information on writing migrations is available here:
- * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
- *
- * The following commands can be used in this method and Phinx will
- * automatically reverse them when rolling back:
- *
- * createTable
- * renameTable
- * addColumn
- * renameColumn
- * addIndex
- * addForeignKey
- *
- * Remember to call "create()" or "update()" and NOT "save()" when working
- * with the Table class.
- */
- public function change()
- {
- //默认数据
- $arr = ['introduce'=>'公司简介#0','pattern'=>'模式优势#0','boutique'=>'精品设计#1','science'=>'材料#0','major'=>'大牌软装#0','customized'=>'定制家具#0','realistic'=>'实景样板房#0','praise'=>'口碑及服务#0','platinum'=>'铂金工程#0'];
- $root_ids = Company::where('1=1')->column('root_id');
- //
- foreach ($root_ids as $v) {
- foreach ($arr as $k2 => $v2) {
- //一级
- $s = explode('#',$v2);
- $pid = SmartScreenCate::insertGetId([
- 'root_id'=>$v,
- 'title'=>$s[0],
- 'code'=>$k2,
- 'pid'=>0,
- 'is_case'=>$s[1],
- 'level'=>1
- ]);
- }
- }
- }
- }
|