table('building_label') ->addColumn('name', 'string', ['comment' => '标签名']) ->addColumn('root_id', 'integer', ['comment' => '企业id']) ->addColumn('addtime', 'integer', ['comment' => '添加时间']) ->create(); $default = ['周边学校', '周边医院', '周边商超', '周边建材', '公园', '小区进度']; $rootList = Company::column('root_id'); $data = []; foreach ($rootList as $id) { foreach ($default as $d) { $data[] = [ 'name' => $d, 'root_id' => $id, 'addtime' => time() ]; } } (new BuildingLabel)->saveAll($data); } }