fixed:模型name属性多加了表前缀
This commit is contained in:
@@ -151,6 +151,18 @@ class Utils
|
|||||||
return \config('database.connections.mysql.prefix');
|
return \config('database.connections.mysql.prefix');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除前缀
|
||||||
|
*
|
||||||
|
* @time 2020年12月01日
|
||||||
|
* @param string $table
|
||||||
|
* @return string|string[]
|
||||||
|
*/
|
||||||
|
public static function tableWithoutPrefix(string $table)
|
||||||
|
{
|
||||||
|
return str_replace(self::tablePrefix(), '', $table);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否是超级管理员
|
* 是否是超级管理员
|
||||||
*
|
*
|
||||||
|
@@ -11,6 +11,7 @@ use catcher\generate\build\classes\Uses;
|
|||||||
use catcher\generate\build\types\Arr;
|
use catcher\generate\build\types\Arr;
|
||||||
use catcher\traits\db\BaseOptionsTrait;
|
use catcher\traits\db\BaseOptionsTrait;
|
||||||
use catcher\traits\db\ScopeTrait;
|
use catcher\traits\db\ScopeTrait;
|
||||||
|
use catcher\Utils;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
use think\helper\Str;
|
use think\helper\Str;
|
||||||
|
|
||||||
@@ -80,7 +81,9 @@ class Model extends Factory
|
|||||||
}
|
}
|
||||||
|
|
||||||
$class->addProperty(
|
$class->addProperty(
|
||||||
(new Property('name'))->default($table)->docComment('// 表名')
|
(new Property('name'))->default(
|
||||||
|
Utils::tableWithoutPrefix($table)
|
||||||
|
)->docComment('// 表名')
|
||||||
);
|
);
|
||||||
|
|
||||||
$class->when($this->hasTableExists($table), function ($class) use ($table){
|
$class->when($this->hasTableExists($table), function ($class) use ($table){
|
||||||
|
Reference in New Issue
Block a user