Browse Source

修复CRUD关联模型下,自定义控制器生成的被关联表模型namespace错误

simon429 4 years ago
parent
commit
48066342da
1 changed files with 5 additions and 5 deletions
  1. 5 5
      application/admin/command/Crud.php

+ 5 - 5
application/admin/command/Crud.php

@@ -26,7 +26,7 @@ class Crud extends Command
      * 受保护的系统表, crud不会生效
      */
     protected $systemTables = [
-       'admin', 'admin_log', 'auth_group', 'auth_group_access', 'auth_rule', 
+       'admin', 'admin_log', 'auth_group', 'auth_group_access', 'auth_rule',
        'attachment', 'config', 'category', 'ems', 'sms',
        'user', 'user_group', 'user_rule', 'user_score_log', 'user_token',
     ];
@@ -214,12 +214,12 @@ class Crud extends Command
         $force = $input->getOption('force');
         //是否为本地model,为0时表示为全局model将会把model放在app/common/model中
         $local = $input->getOption('local');
-        
+
         if (!$table) {
             throw new Exception('table name can\'t empty');
         }
-        
-    
+
+
         //是否生成菜单
         $menu = $input->getOption("menu");
         //关联表
@@ -963,7 +963,7 @@ class Crud extends Command
 
             if ($relations) {
                 foreach ($relations as $i => $relation) {
-                    $relation['modelNamespace'] = $data['modelNamespace'];
+                    $relation['modelNamespace'] = $relation['relationNamespace'];
                     if (!is_file($relation['relationFile'])) {
                         // 生成关联模型文件
                         $this->writeToFile('relationmodel', $relation, $relation['relationFile']);