InstallCommand.php 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace Illuminate\Database\Console\Migrations;
  3. use Illuminate\Console\Command;
  4. use Symfony\Component\Console\Input\InputOption;
  5. use Illuminate\Database\Migrations\MigrationRepositoryInterface;
  6. class InstallCommand extends Command
  7. {
  8. /**
  9. * The console command name.
  10. *
  11. * @var string
  12. */
  13. protected $name = 'migrate:install';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = 'Create the migration repository';
  20. /**
  21. * The repository instance.
  22. *
  23. * @var \Illuminate\Database\Migrations\MigrationRepositoryInterface
  24. */
  25. protected $repository;
  26. /**
  27. * Create a new migration install command instance.
  28. *
  29. * @param \Illuminate\Database\Migrations\MigrationRepositoryInterface $repository
  30. * @return void
  31. */
  32. public function __construct(MigrationRepositoryInterface $repository)
  33. {
  34. parent::__construct();
  35. $this->repository = $repository;
  36. }
  37. /**
  38. * Execute the console command.
  39. *
  40. * @return void
  41. */
  42. public function handle()
  43. {
  44. $this->repository->setSource($this->input->getOption('database'));
  45. $this->repository->createRepository();
  46. $this->info('Migration table created successfully.');
  47. }
  48. /**
  49. * Get the console command options.
  50. *
  51. * @return array
  52. */
  53. protected function getOptions()
  54. {
  55. return [
  56. ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'],
  57. ];
  58. }
  59. }