feat: 支持已有表生成代码
This commit is contained in:
28
modules/Common/Repository/Options/Schemas.php
Normal file
28
modules/Common/Repository/Options/Schemas.php
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user