求助老司机
function create ($_input) {
foreach ($_input as $table => $columns) {
Manager::schema()->hasTable($table) OR
Manager::schema()->create($table, function ($table) use ($columns) {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
foreach ($columns as $name => $attributes) {
list($name, $attributes[0]) = [ $attributes[0], $name ];
call_user_func_array([$table, $name], $attributes);
}
});
}
}
函数的作用是接收一个数组参数
转变为 schema
的形式,使用 eloquent
这个方法该怎么重构,使之看上去优雅?