update:class增加when方法

This commit is contained in:
JaguarJack
2020-11-19 19:11:18 +08:00
parent 0dfe4fb5c6
commit 21c1df4f69
2 changed files with 24 additions and 5 deletions

View File

@@ -83,11 +83,13 @@ class Model extends Factory
(new Property('name'))->default($table)->docComment('// 表名')
);
$class->addProperty(
(new Property('field'))->default(
(new Arr)->build(Db::getFields($table))
)->docComment('// 数据库字段映射')
);
$class->when($this->hasTableExists($table), function ($class) use ($table){
$class->addProperty(
(new Property('field'))->default(
(new Arr)->build(Db::getFields($table))
))->docComment('// 数据库字段映射');
});
})->getContent();
}
}