From c03213e7c3204315692f6b9f4e6ee66110cfab8f Mon Sep 17 00:00:00 2001 From: JaguarJack <82664165@qq.com> Date: Sun, 22 Dec 2024 07:46:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E5=B7=B2=E6=9C=89?= =?UTF-8?q?=E8=A1=A8=E7=94=9F=E6=88=90=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/Common/Repository/Options/Schemas.php | 28 +++++++++++++++++++ modules/Develop/Models/Schemas.php | 12 ++++++++ 2 files changed, 40 insertions(+) create mode 100644 modules/Common/Repository/Options/Schemas.php 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'];