Procházet zdrojové kódy

增加action以及form生成命令对非app目录的支持

jqh před 5 roky
rodič
revize
056e4828b6

+ 1 - 3
src/Console/ActionCommand.php

@@ -64,9 +64,7 @@ class ActionCommand extends GeneratorCommand
 
         $this->namespace = ucfirst(trim($this->ask('Please enter the namespace of action class', $this->getDefaultNamespace(null))));
 
-        if (! Str::startsWith(config('admin.route.namespace'), 'App')) {
-            $this->baseDirectory = trim($this->ask('Please enter the destination class path', 'app'));
-        }
+        $this->askBaseDirectory();
 
         return parent::handle();
     }

+ 1 - 3
src/Console/FormCommand.php

@@ -29,9 +29,7 @@ class FormCommand extends GeneratorCommand
      */
     public function handle()
     {
-        if (! Str::startsWith(config('admin.route.namespace'), 'App')) {
-            $this->baseDirectory = trim($this->ask('Please enter the destination class path', 'app'));
-        }
+        $this->askBaseDirectory();
 
         return parent::handle(); // TODO: Change the autogenerated stub
     }

+ 13 - 0
src/Console/GeneratorCommand.php

@@ -2,6 +2,7 @@
 
 namespace Dcat\Admin\Console;
 
+use Dcat\Admin\Support\Helper;
 use Illuminate\Console\GeneratorCommand as BaseCommand;
 use Illuminate\Support\Str;
 
@@ -47,4 +48,16 @@ abstract class GeneratorCommand extends BaseCommand
 
         return $this->laravel['path'];
     }
+
+    /**
+     * @return void
+     */
+    protected function askBaseDirectory()
+    {
+        if (! Str::startsWith(config('admin.route.namespace'), 'App')) {
+            $dir = explode('\\', config('admin.route.namespace'))[0];
+
+            $this->baseDirectory = trim($this->ask('Please enter the destination class path', Helper::slug($dir)));
+        }
+    }
 }