如何循环生成迁移表
代码如下
foreach ($this->table_arr as $key=> $device) {
Schema::create('rd_'.$key, function (Blueprint $table) {
$table->id();
$table->timestamps();
//状态
foreach ($device['status'] as $key1 => $value) {
$table->tinyInteger($key1)->comment($value);
}
// 数据
foreach ($device['data'] as $key1 => $value) {
$table->float($key1, 8, 2)->comment($value);
}
// 额定
foreach ($device['rated'] as $key1 => $value) {
$table->char($key1, 40)->comment($value);
}
});
}
推荐文章: