BaseCommand.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Illuminate\Database\Console\Migrations;
  3. use Illuminate\Console\Command;
  4. class BaseCommand extends Command
  5. {
  6. /**
  7. * Get all of the migration paths.
  8. *
  9. * @return array
  10. */
  11. protected function getMigrationPaths()
  12. {
  13. // Here, we will check to see if a path option has been defined. If it has we will
  14. // use the path relative to the root of the installation folder so our database
  15. // migrations may be run for any customized path from within the application.
  16. if ($this->input->hasOption('path') && $this->option('path')) {
  17. return collect($this->option('path'))->map(function ($path) {
  18. return ! $this->usingRealPath()
  19. ? $this->laravel->basePath().'/'.$path
  20. : $path;
  21. })->all();
  22. }
  23. return array_merge(
  24. $this->migrator->paths(), [$this->getMigrationPath()]
  25. );
  26. }
  27. /**
  28. * Determine if the given path(s) are pre-resolved "real" paths.
  29. *
  30. * @return bool
  31. */
  32. protected function usingRealPath()
  33. {
  34. return $this->input->hasOption('realpath') && $this->option('realpath');
  35. }
  36. /**
  37. * Get the path to the migration directory.
  38. *
  39. * @return string
  40. */
  41. protected function getMigrationPath()
  42. {
  43. return $this->laravel->databasePath().DIRECTORY_SEPARATOR.'migrations';
  44. }
  45. }