curd支持控制器多个关联

This commit is contained in:
2022-08-22 17:26:16 +08:00
parent 43edf2fa62
commit 01c810b1e9

View File

@@ -1070,10 +1070,13 @@ class BuildCurdService
$controllerExportMethod = ''; $controllerExportMethod = '';
} else { } else {
$relationCode = ''; $relationCode = '';
$relation_table = [];
foreach ($this->relationArray as $key => $val) { foreach ($this->relationArray as $key => $val) {
$relation = Str::camel($key); $relation = Str::camel($key);
$relationCode = "->withJoin('{$relation}', 'LEFT')\r"; $relation_table[] = $relation;
} }
$relationCode = "->withJoin(['" . implode('\',\'', $relation_table) . "'], 'LEFT')\r";
$controllerIndexMethod = $this->replaceTemplate( $controllerIndexMethod = $this->replaceTemplate(
$this->getTemplate("controller{$this->DS}indexMethod"), $this->getTemplate("controller{$this->DS}indexMethod"),
[ [