diff --git a/modules/Common/Repository/Options/Schemas.php b/modules/Common/Repository/Options/Schemas.php new file mode 100644 index 0000000..aea70c7 --- /dev/null +++ b/modules/Common/Repository/Options/Schemas.php @@ -0,0 +1,28 @@ +getTablePrefix(); + + foreach (Schema::getTables() as $table) { + $tableName = Str::of($table['name'])->remove($tablePrefix); + + $options[] = [ + 'label' => $tableName . "\t\t\t\t" . $table['comment'], + 'value' => $tableName, + ]; + } + + return $options; + } +} diff --git a/modules/Develop/Models/Schemas.php b/modules/Develop/Models/Schemas.php index f6b4598..2a195cc 100644 --- a/modules/Develop/Models/Schemas.php +++ b/modules/Develop/Models/Schemas.php @@ -48,6 +48,18 @@ class Schemas extends CatchModel */ public function storeBy(array $data): bool { + // 从已有 schema 中选择 + if (isset($data['schema_name'])) { + $columns = SchemaFacade::getColumnListing($data['schema_name']); + + return parent::storeBy([ + 'module' => $data['module'], + 'name' => $data['schema_name'], + 'columns' => implode(',', $columns), + 'is_soft_delete' => isset($columns['deleted_at']) ? Status::Enable : Status::Disable, + ]); + } + $schema = $data['schema']; $structures = $data['structures'];