mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-10 03:42:49 +08:00
优化助手函数,使用tp内置的库替换;
This commit is contained in:
@@ -301,7 +301,7 @@ class BuildCurdService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 初始化默认模型名
|
// 初始化默认模型名
|
||||||
$this->modelFilename = ucfirst(CommonTool::lineToHump($this->table));
|
$this->modelFilename = Str::studly($this->table);
|
||||||
|
|
||||||
$this->buildViewJsUrl();
|
$this->buildViewJsUrl();
|
||||||
|
|
||||||
@@ -358,7 +358,7 @@ class BuildCurdService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$modelFilename = empty($modelFilename) ? ucfirst(CommonTool::lineToHump($relationTable)) : $modelFilename;
|
$modelFilename = empty($modelFilename) ? Str::studly($relationTable) : $modelFilename;
|
||||||
$modelArray = explode($this->DS, $modelFilename);
|
$modelArray = explode($this->DS, $modelFilename);
|
||||||
$modelName = array_pop($modelArray);
|
$modelName = array_pop($modelArray);
|
||||||
|
|
||||||
@@ -580,7 +580,7 @@ class BuildCurdService
|
|||||||
$nodeArray = explode($this->DS, $this->controllerFilename);
|
$nodeArray = explode($this->DS, $this->controllerFilename);
|
||||||
$formatArray = [];
|
$formatArray = [];
|
||||||
foreach ($nodeArray as $vo) {
|
foreach ($nodeArray as $vo) {
|
||||||
$formatArray[] = CommonTool::humpToLine(lcfirst($vo));
|
$formatArray[] = Str::snake($vo);
|
||||||
}
|
}
|
||||||
$this->controllerUrl = implode('.', $formatArray);
|
$this->controllerUrl = implode('.', $formatArray);
|
||||||
$this->viewFilename = implode($this->DS, $formatArray);
|
$this->viewFilename = implode($this->DS, $formatArray);
|
||||||
@@ -1009,7 +1009,7 @@ class BuildCurdService
|
|||||||
} else {
|
} else {
|
||||||
$relationCode = '';
|
$relationCode = '';
|
||||||
foreach ($this->relationArray as $key => $val) {
|
foreach ($this->relationArray as $key => $val) {
|
||||||
$relation = CommonTool::lineToHump($key);
|
$relation = Str::camel($key);
|
||||||
$relationCode = "->withJoin('{$relation}', 'LEFT')\r";
|
$relationCode = "->withJoin('{$relation}', 'LEFT')\r";
|
||||||
}
|
}
|
||||||
$controllerIndexMethod = CommonTool::replaceTemplate(
|
$controllerIndexMethod = CommonTool::replaceTemplate(
|
||||||
@@ -1062,7 +1062,7 @@ class BuildCurdService
|
|||||||
} else {
|
} else {
|
||||||
$relationList = '';
|
$relationList = '';
|
||||||
foreach ($this->relationArray as $key => $val) {
|
foreach ($this->relationArray as $key => $val) {
|
||||||
$relation = CommonTool::lineToHump($key);
|
$relation = Str::camel($key);
|
||||||
$relationCode = CommonTool::replaceTemplate(
|
$relationCode = CommonTool::replaceTemplate(
|
||||||
$this->getTemplate("model{$this->DS}relation"),
|
$this->getTemplate("model{$this->DS}relation"),
|
||||||
[
|
[
|
||||||
@@ -1116,7 +1116,7 @@ class BuildCurdService
|
|||||||
$relationModelClass = "\\app\\admin\\model\\{$val['modelFilename']}";
|
$relationModelClass = "\\app\\admin\\model\\{$val['modelFilename']}";
|
||||||
if (class_exists($relationModelClass) && method_exists(new $relationModelClass, 'getName')) {
|
if (class_exists($relationModelClass) && method_exists(new $relationModelClass, 'getName')) {
|
||||||
$tableName = (new $relationModelClass)->getName();
|
$tableName = (new $relationModelClass)->getName();
|
||||||
if (CommonTool::humpToLine(lcfirst($tableName)) == CommonTool::humpToLine(lcfirst($key))) {
|
if (Str::snake($tableName) == Str::snake($key)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1375,7 +1375,7 @@ class BuildCurdService
|
|||||||
|
|
||||||
// 关联表
|
// 关联表
|
||||||
foreach ($this->relationArray as $table => $tableVal) {
|
foreach ($this->relationArray as $table => $tableVal) {
|
||||||
$table = CommonTool::lineToHump($table);
|
$table = Str::camel($table);
|
||||||
foreach ($tableVal['tableColumns'] as $field => $val) {
|
foreach ($tableVal['tableColumns'] as $field => $val) {
|
||||||
if ($val['formType'] == 'image') {
|
if ($val['formType'] == 'image') {
|
||||||
$templateValue = "{field: '{$table}.{$field}', title: '{$val['comment']}', templet: ea.table.image}";
|
$templateValue = "{field: '{$table}.{$field}', title: '{$val['comment']}', templet: ea.table.image}";
|
||||||
|
|||||||
Reference in New Issue
Block a user