feat: 支持已有表生成代码

This commit is contained in:
JaguarJack
2024-12-22 07:46:20 +08:00
parent 3867be14b2
commit c03213e7c3
2 changed files with 40 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
<?php
namespace Modules\Common\Repository\Options;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
class Schemas implements OptionInterface
{
public function get(): array
{
$options = [];
$tablePrefix = DB::connection()->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;
}
}