Skip to content

Commit

Permalink
Merge pull request #5 from zhongshaofa/fix-curd
Browse files Browse the repository at this point in the history
判断关联模型文件是否存在, 存在就不重新生成文件, 防止关联模型文件被覆盖
  • Loading branch information
zhongshaofa committed Jun 17, 2020
2 parents 82e2656 + 261c8a2 commit f8527e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ runtime/temp
public/conf
public/WowOss.exe
app/index/controller/Test.php
composer.phar
composer.phar
app/test/
10 changes: 10 additions & 0 deletions vendor/zhongshaofa/easy-admin/src/curd/BuildCurd.php
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,16 @@ protected function renderModel()
// 关联模型
foreach ($this->relationArray as $key => $val) {
$relationModelFile = "{$this->rootDir}app{$this->DS}admin{$this->DS}model{$this->DS}{$val['modelFilename']}.php";

// todo 判断关联模型文件是否存在, 存在就不重新生成文件, 防止关联模型文件被覆盖
$relationModelClass = "\\app\\admin\\model\\{$val['modelFilename']}";
if (class_exists($relationModelClass) && method_exists(new $relationModelClass, 'getName')) {
$tableName = (new $relationModelClass)->getName();
if (CommonTool::humpToLine(lcfirst($tableName)) == CommonTool::humpToLine(lcfirst($key))) {
continue;
}
}

$relationModelValue = CommonTool::replaceTemplate(
$this->getTemplate("model{$this->DS}model"),
[
Expand Down

0 comments on commit f8527e4

Please sign in to comment.