FormCommand.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace Dcat\Admin\Console;
  3. class FormCommand extends GeneratorCommand
  4. {
  5. /**
  6. * The console command name.
  7. *
  8. * @var string
  9. */
  10. protected $signature = 'admin:form {name}
  11. {--namespace=}
  12. {--base=}';
  13. /**
  14. * The console command description.
  15. *
  16. * @var string
  17. */
  18. protected $description = 'Make admin form widget';
  19. /**
  20. * @return bool|null
  21. *
  22. * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  23. */
  24. public function handle()
  25. {
  26. $this->askBaseDirectory();
  27. return parent::handle(); // TODO: Change the autogenerated stub
  28. }
  29. /**
  30. * Get the stub file for the generator.
  31. *
  32. * @return string
  33. */
  34. protected function getStub()
  35. {
  36. return __DIR__.'/stubs/form.stub';
  37. }
  38. /**
  39. * Get the default namespace for the class.
  40. *
  41. * @param string $rootNamespace
  42. *
  43. * @return string
  44. */
  45. protected function getDefaultNamespace($rootNamespace)
  46. {
  47. if ($namespace = $this->option('namespace')) {
  48. return $namespace;
  49. }
  50. return str_replace('Controllers', 'Forms', config('admin.route.namespace'));
  51. }
  52. /**
  53. * Get the desired class name from the input.
  54. *
  55. * @return string
  56. */
  57. protected function getNameInput()
  58. {
  59. $name = trim($this->argument('name'));
  60. $this->type = $this->qualifyClass($name);
  61. return $name;
  62. }
  63. }