SeederMakeCommand.php 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace Illuminate\Database\Console\Seeds;
  3. use Illuminate\Support\Composer;
  4. use Illuminate\Filesystem\Filesystem;
  5. use Illuminate\Console\GeneratorCommand;
  6. class SeederMakeCommand extends GeneratorCommand
  7. {
  8. /**
  9. * The console command name.
  10. *
  11. * @var string
  12. */
  13. protected $name = 'make:seeder';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = 'Create a new seeder class';
  20. /**
  21. * The type of class being generated.
  22. *
  23. * @var string
  24. */
  25. protected $type = 'Seeder';
  26. /**
  27. * The Composer instance.
  28. *
  29. * @var \Illuminate\Support\Composer
  30. */
  31. protected $composer;
  32. /**
  33. * Create a new command instance.
  34. *
  35. * @param \Illuminate\Filesystem\Filesystem $files
  36. * @param \Illuminate\Support\Composer $composer
  37. * @return void
  38. */
  39. public function __construct(Filesystem $files, Composer $composer)
  40. {
  41. parent::__construct($files);
  42. $this->composer = $composer;
  43. }
  44. /**
  45. * Execute the console command.
  46. *
  47. * @return void
  48. */
  49. public function handle()
  50. {
  51. parent::handle();
  52. $this->composer->dumpAutoloads();
  53. }
  54. /**
  55. * Get the stub file for the generator.
  56. *
  57. * @return string
  58. */
  59. protected function getStub()
  60. {
  61. return __DIR__.'/stubs/seeder.stub';
  62. }
  63. /**
  64. * Get the destination class path.
  65. *
  66. * @param string $name
  67. * @return string
  68. */
  69. protected function getPath($name)
  70. {
  71. return $this->laravel->databasePath().'/seeds/'.$name.'.php';
  72. }
  73. /**
  74. * Parse the class name and format according to the root namespace.
  75. *
  76. * @param string $name
  77. * @return string
  78. */
  79. protected function qualifyClass($name)
  80. {
  81. return $name;
  82. }
  83. }