| @@ -8,41 +8,41 @@ | ||
| 8 | 8 | |
| 9 | 9 | class MigrationsOrganiserServiceProvider extends MSP | 
| 10 | 10 |  { | 
| 11 | - public function register() | |
| 12 | -    { | |
| 13 | - parent::register(); | |
| 14 | - $this->registerMigrateOrganise(); | |
| 15 | - $this->registerMigrateDisorganise(); | |
| 16 | -        $this->commands('command.migrate.organise', 'command.migrate.disorganise'); | |
| 17 | - } | |
| 18 | - | |
| 19 | - protected function registerCreator() | |
| 20 | -    { | |
| 21 | -        $this->app->singleton('migration.creator', function ($app) { | |
| 22 | - return new MigrationCreator($app['files']); | |
| 23 | - }); | |
| 24 | - } | |
| 25 | - | |
| 26 | - protected function registerMigrator() | |
| 27 | -    { | |
| 28 | -        $this->app->singleton('migrator', function ($app) { | |
| 29 | - $repository = $app['migration.repository']; | |
| 30 | - | |
| 31 | - return new Migrator($repository, $app['db'], $app['files']); | |
| 32 | - }); | |
| 33 | - } | |
| 34 | - | |
| 35 | - protected function registerMigrateOrganise() | |
| 36 | -    { | |
| 37 | -        $this->app->singleton('command.migrate.organise', function ($app) { | |
| 38 | - return new MigrateOrganise($app['files'], $app['migrator']); | |
| 39 | - }); | |
| 40 | - } | |
| 41 | - | |
| 42 | - protected function registerMigrateDisorganise() | |
| 43 | -    { | |
| 44 | -        $this->app->singleton('command.migrate.disorganise', function ($app) { | |
| 45 | - return new MigrateDisorganise($app['files'], $app['migrator']); | |
| 46 | - }); | |
| 47 | - } | |
| 11 | + public function register() | |
| 12 | +	{ | |
| 13 | + parent::register(); | |
| 14 | + $this->registerMigrateOrganise(); | |
| 15 | + $this->registerMigrateDisorganise(); | |
| 16 | +		$this->commands('command.migrate.organise', 'command.migrate.disorganise'); | |
| 17 | + } | |
| 18 | + | |
| 19 | + protected function registerCreator() | |
| 20 | +	{ | |
| 21 | +		$this->app->singleton('migration.creator', function ($app) { | |
| 22 | + return new MigrationCreator($app['files']); | |
| 23 | + }); | |
| 24 | + } | |
| 25 | + | |
| 26 | + protected function registerMigrator() | |
| 27 | +	{ | |
| 28 | +		$this->app->singleton('migrator', function ($app) { | |
| 29 | + $repository = $app['migration.repository']; | |
| 30 | + | |
| 31 | + return new Migrator($repository, $app['db'], $app['files']); | |
| 32 | + }); | |
| 33 | + } | |
| 34 | + | |
| 35 | + protected function registerMigrateOrganise() | |
| 36 | +	{ | |
| 37 | +		$this->app->singleton('command.migrate.organise', function ($app) { | |
| 38 | + return new MigrateOrganise($app['files'], $app['migrator']); | |
| 39 | + }); | |
| 40 | + } | |
| 41 | + | |
| 42 | + protected function registerMigrateDisorganise() | |
| 43 | +	{ | |
| 44 | +		$this->app->singleton('command.migrate.disorganise', function ($app) { | |
| 45 | + return new MigrateDisorganise($app['files'], $app['migrator']); | |
| 46 | + }); | |
| 47 | + } | |
| 48 | 48 | } | 
| @@ -6,14 +6,14 @@ | ||
| 6 | 6 | |
| 7 | 7 | class MigrationCreator extends MC | 
| 8 | 8 |  { | 
| 9 | - protected function getPath($name, $path) | |
| 10 | -    { | |
| 11 | -        $path = $path.'/'.date('Y').'/'.date('m'); | |
| 9 | + protected function getPath($name, $path) | |
| 10 | +	{ | |
| 11 | +		$path = $path.'/'.date('Y').'/'.date('m'); | |
| 12 | 12 | |
| 13 | -        if (! $this->files->exists($path)) { | |
| 14 | - $this->files->makeDirectory($path, 0775, true); | |
| 15 | - } | |
| 13 | +		if (! $this->files->exists($path)) { | |
| 14 | + $this->files->makeDirectory($path, 0775, true); | |
| 15 | + } | |
| 16 | 16 | |
| 17 | - return $path.'/'.$this->getDatePrefix().'_'.$name.'.php'; | |
| 18 | - } | |
| 17 | + return $path.'/'.$this->getDatePrefix().'_'.$name.'.php'; | |
| 18 | + } | |
| 19 | 19 | } | 
| @@ -18,7 +18,7 @@ | ||
| 18 | 18 | /** | 
| 19 | 19 | * Get all of the migration files in a given path. | 
| 20 | 20 | * | 
| 21 | - * @param string $path | |
| 21 | + * @param string $paths | |
| 22 | 22 | * @param bool $recursive | 
| 23 | 23 | * | 
| 24 | 24 | * @return array | 
| @@ -8,71 +8,71 @@ | ||
| 8 | 8 | |
| 9 | 9 | class Migrator extends M | 
| 10 | 10 |  { | 
| 11 | - /** | |
| 12 | - * Get all of the migration files in a given path. | |
| 13 | - * | |
| 14 | - * @param string $path | |
| 15 | - * @param bool $recursive | |
| 16 | - * | |
| 17 | - * @return array | |
| 18 | - */ | |
| 19 | - public function getMigrationFiles($paths = [], $recursive = true) | |
| 20 | -    { | |
| 21 | -        if ($recursive) { | |
| 22 | - $paths = $this->getRecursiveFolders($paths); | |
| 23 | - } | |
| 11 | + /** | |
| 12 | + * Get all of the migration files in a given path. | |
| 13 | + * | |
| 14 | + * @param string $path | |
| 15 | + * @param bool $recursive | |
| 16 | + * | |
| 17 | + * @return array | |
| 18 | + */ | |
| 19 | + public function getMigrationFiles($paths = [], $recursive = true) | |
| 20 | +	{ | |
| 21 | +		if ($recursive) { | |
| 22 | + $paths = $this->getRecursiveFolders($paths); | |
| 23 | + } | |
| 24 | 24 | |
| 25 | - $files = parent::getMigrationFiles($paths); | |
| 25 | + $files = parent::getMigrationFiles($paths); | |
| 26 | 26 | |
| 27 | - return $files; | |
| 28 | - } | |
| 27 | + return $files; | |
| 28 | + } | |
| 29 | 29 | |
| 30 | - /** | |
| 31 | - * Get all subdirectories located in an array of folders. | |
| 32 | - * | |
| 33 | - * @param array $folders | |
| 34 | - * | |
| 35 | - * @return array | |
| 36 | - */ | |
| 37 | - public function getRecursiveFolders($folders) | |
| 38 | -    { | |
| 39 | -        if (! is_array($folders)) { | |
| 40 | - $folders = [$folders]; | |
| 41 | - } | |
| 30 | + /** | |
| 31 | + * Get all subdirectories located in an array of folders. | |
| 32 | + * | |
| 33 | + * @param array $folders | |
| 34 | + * | |
| 35 | + * @return array | |
| 36 | + */ | |
| 37 | + public function getRecursiveFolders($folders) | |
| 38 | +	{ | |
| 39 | +		if (! is_array($folders)) { | |
| 40 | + $folders = [$folders]; | |
| 41 | + } | |
| 42 | 42 | |
| 43 | - $paths = []; | |
| 43 | + $paths = []; | |
| 44 | 44 | |
| 45 | -        foreach ($folders as $folder) { | |
| 46 | - $iter = new Iterator( | |
| 47 | - new DirectoryIterator($folder, DirectoryIterator::SKIP_DOTS), | |
| 48 | - Iterator::SELF_FIRST, | |
| 49 | - Iterator::CATCH_GET_CHILD // Ignore "Permission denied" | |
| 50 | - ); | |
| 45 | +		foreach ($folders as $folder) { | |
| 46 | + $iter = new Iterator( | |
| 47 | + new DirectoryIterator($folder, DirectoryIterator::SKIP_DOTS), | |
| 48 | + Iterator::SELF_FIRST, | |
| 49 | + Iterator::CATCH_GET_CHILD // Ignore "Permission denied" | |
| 50 | + ); | |
| 51 | 51 | |
| 52 | - $subPaths = [$folder]; | |
| 53 | -            foreach ($iter as $path => $dir) { | |
| 54 | -                if ($dir->isDir()) { | |
| 55 | - $subPaths[] = $path; | |
| 56 | - } | |
| 57 | - } | |
| 52 | + $subPaths = [$folder]; | |
| 53 | +			foreach ($iter as $path => $dir) { | |
| 54 | +				if ($dir->isDir()) { | |
| 55 | + $subPaths[] = $path; | |
| 56 | + } | |
| 57 | + } | |
| 58 | 58 | |
| 59 | - $paths = array_merge($paths, $subPaths); | |
| 60 | - } | |
| 59 | + $paths = array_merge($paths, $subPaths); | |
| 60 | + } | |
| 61 | 61 | |
| 62 | - return $paths; | |
| 63 | - } | |
| 62 | + return $paths; | |
| 63 | + } | |
| 64 | 64 | |
| 65 | - /** | |
| 66 | - * Add date folders to migrations path. | |
| 67 | - * | |
| 68 | - * @param string $file | |
| 69 | - * | |
| 70 | - * @return string | |
| 71 | - */ | |
| 72 | - public function getDateFolderStructure($file) | |
| 73 | -    { | |
| 74 | -        $parts = explode('_', $file); | |
| 65 | + /** | |
| 66 | + * Add date folders to migrations path. | |
| 67 | + * | |
| 68 | + * @param string $file | |
| 69 | + * | |
| 70 | + * @return string | |
| 71 | + */ | |
| 72 | + public function getDateFolderStructure($file) | |
| 73 | +	{ | |
| 74 | +		$parts = explode('_', $file); | |
| 75 | 75 | |
| 76 | - return $parts[0].'/'.$parts[1].'/'; | |
| 77 | - } | |
| 76 | + return $parts[0].'/'.$parts[1].'/'; | |
| 77 | + } | |
| 78 | 78 | } | 
| @@ -8,84 +8,84 @@ | ||
| 8 | 8 | |
| 9 | 9 | class MigrateOrganise extends BaseCommand | 
| 10 | 10 |  { | 
| 11 | - /** | |
| 12 | - * The console command name. | |
| 13 | - * | |
| 14 | - * @var string | |
| 15 | - */ | |
| 16 | - protected $name = 'migrate:organise'; | |
| 11 | + /** | |
| 12 | + * The console command name. | |
| 13 | + * | |
| 14 | + * @var string | |
| 15 | + */ | |
| 16 | + protected $name = 'migrate:organise'; | |
| 17 | 17 | |
| 18 | - /** | |
| 19 | - * The console command description. | |
| 20 | - * | |
| 21 | - * @var string | |
| 22 | - */ | |
| 23 | - protected $description = 'Move migrations into a yyyy/mm folder structure'; | |
| 18 | + /** | |
| 19 | + * The console command description. | |
| 20 | + * | |
| 21 | + * @var string | |
| 22 | + */ | |
| 23 | + protected $description = 'Move migrations into a yyyy/mm folder structure'; | |
| 24 | 24 | |
| 25 | - /** | |
| 26 | - * The migrator instance. | |
| 27 | - * | |
| 28 | - * @var \Jaybizzle\MigrationsOrganiser\Migrator | |
| 29 | - */ | |
| 30 | - protected $migrator; | |
| 25 | + /** | |
| 26 | + * The migrator instance. | |
| 27 | + * | |
| 28 | + * @var \Jaybizzle\MigrationsOrganiser\Migrator | |
| 29 | + */ | |
| 30 | + protected $migrator; | |
| 31 | 31 | |
| 32 | - /** | |
| 33 | - * The filesystem instance. | |
| 34 | - * | |
| 35 | - * @var \Illuminate\Filesystem\Filesystem | |
| 36 | - */ | |
| 37 | - protected $files; | |
| 32 | + /** | |
| 33 | + * The filesystem instance. | |
| 34 | + * | |
| 35 | + * @var \Illuminate\Filesystem\Filesystem | |
| 36 | + */ | |
| 37 | + protected $files; | |
| 38 | 38 | |
| 39 | - /** | |
| 40 | - * Create a new migrator instance. | |
| 41 | - * | |
| 42 | - * @param \Illuminate\Filesystem\Filesystem $files | |
| 43 | - * @param \Illuminate\Database\Migrations\Migrator $migrator | |
| 44 | - */ | |
| 45 | - public function __construct(Filesystem $files, Migrator $migrator) | |
| 46 | -    { | |
| 47 | - parent::__construct(); | |
| 48 | - $this->migrator = $migrator; | |
| 49 | - $this->files = $files; | |
| 50 | - } | |
| 39 | + /** | |
| 40 | + * Create a new migrator instance. | |
| 41 | + * | |
| 42 | + * @param \Illuminate\Filesystem\Filesystem $files | |
| 43 | + * @param \Illuminate\Database\Migrations\Migrator $migrator | |
| 44 | + */ | |
| 45 | + public function __construct(Filesystem $files, Migrator $migrator) | |
| 46 | +	{ | |
| 47 | + parent::__construct(); | |
| 48 | + $this->migrator = $migrator; | |
| 49 | + $this->files = $files; | |
| 50 | + } | |
| 51 | 51 | |
| 52 | - /** | |
| 53 | - * Fire the command. (Compatibility for < 5.5). | |
| 54 | - */ | |
| 55 | - public function fire() | |
| 56 | -    { | |
| 57 | - $this->handle(); | |
| 58 | - } | |
| 52 | + /** | |
| 53 | + * Fire the command. (Compatibility for < 5.5). | |
| 54 | + */ | |
| 55 | + public function fire() | |
| 56 | +	{ | |
| 57 | + $this->handle(); | |
| 58 | + } | |
| 59 | 59 | |
| 60 | - /** | |
| 61 | - * Create date folder structure and move migrations into. | |
| 62 | - * | |
| 63 | - * @return void | |
| 64 | - */ | |
| 65 | - public function handle() | |
| 66 | -    { | |
| 67 | - $basePath = $this->getMigrationPath(); | |
| 68 | - $migrations = $this->migrator->getMigrationFiles($basePath, false); | |
| 69 | - $count = count($migrations); | |
| 60 | + /** | |
| 61 | + * Create date folder structure and move migrations into. | |
| 62 | + * | |
| 63 | + * @return void | |
| 64 | + */ | |
| 65 | + public function handle() | |
| 66 | +	{ | |
| 67 | + $basePath = $this->getMigrationPath(); | |
| 68 | + $migrations = $this->migrator->getMigrationFiles($basePath, false); | |
| 69 | + $count = count($migrations); | |
| 70 | 70 | |
| 71 | -        if ($count == 0) { | |
| 72 | -            $this->comment('No migrations to move'); | |
| 71 | +		if ($count == 0) { | |
| 72 | +			$this->comment('No migrations to move'); | |
| 73 | 73 | |
| 74 | - return; | |
| 75 | - } | |
| 74 | + return; | |
| 75 | + } | |
| 76 | 76 | |
| 77 | -        foreach ($migrations as $migration_name => $migration_path) { | |
| 78 | - $datePath = $this->migrator->getDateFolderStructure($migration_name); | |
| 77 | +		foreach ($migrations as $migration_name => $migration_path) { | |
| 78 | + $datePath = $this->migrator->getDateFolderStructure($migration_name); | |
| 79 | 79 | |
| 80 | - // Create folder if it does not already exist | |
| 81 | -            if (! $this->files->exists($basePath.'/'.$datePath)) { | |
| 82 | - $this->files->makeDirectory($basePath.'/'.$datePath, 0775, true); | |
| 83 | - } | |
| 80 | + // Create folder if it does not already exist | |
| 81 | +			if (! $this->files->exists($basePath.'/'.$datePath)) { | |
| 82 | + $this->files->makeDirectory($basePath.'/'.$datePath, 0775, true); | |
| 83 | + } | |
| 84 | 84 | |
| 85 | - // Move the migration into its new folder | |
| 86 | - $this->files->move($basePath.'/'.$migration_name.'.php', $basePath.'/'.$datePath.$migration_name.'.php'); | |
| 87 | - } | |
| 85 | + // Move the migration into its new folder | |
| 86 | + $this->files->move($basePath.'/'.$migration_name.'.php', $basePath.'/'.$datePath.$migration_name.'.php'); | |
| 87 | + } | |
| 88 | 88 | |
| 89 | -        $this->info('Migrations organised successfully ('.$count.' migrations moved)'); | |
| 90 | - } | |
| 89 | +		$this->info('Migrations organised successfully ('.$count.' migrations moved)'); | |
| 90 | + } | |
| 91 | 91 | } | 
| @@ -9,126 +9,126 @@ | ||
| 9 | 9 | |
| 10 | 10 | class MigrateDisorganise extends BaseCommand | 
| 11 | 11 |  { | 
| 12 | - /** | |
| 13 | - * The console command name. | |
| 14 | - * | |
| 15 | - * @var string | |
| 16 | - */ | |
| 17 | - protected $name = 'migrate:disorganise'; | |
| 18 | - | |
| 19 | - /** | |
| 20 | - * The console command description. | |
| 21 | - * | |
| 22 | - * @var string | |
| 23 | - */ | |
| 24 | - protected $description = 'Move migrations from a yyyy/mm folder structure back to the base migrations folder'; | |
| 25 | - | |
| 26 | - /** | |
| 27 | - * The migrator instance. | |
| 28 | - * | |
| 29 | - * @var \Jaybizzle\MigrationsOrganiser\Migrator | |
| 30 | - */ | |
| 31 | - protected $migrator; | |
| 32 | - | |
| 33 | - /** | |
| 34 | - * The filesystem instance. | |
| 35 | - * | |
| 36 | - * @var \Illuminate\Filesystem\Filesystem | |
| 37 | - */ | |
| 38 | - protected $files; | |
| 39 | - | |
| 40 | - /** | |
| 41 | - * The basePath for the migrations. | |
| 42 | - */ | |
| 43 | - protected $basePath; | |
| 44 | - | |
| 45 | - /** | |
| 46 | - * Create a new migrator instance. | |
| 47 | - * | |
| 48 | - * @param \Illuminate\Filesystem\Filesystem $files | |
| 49 | - * @param \Illuminate\Database\Migrations\Migrator $migrator | |
| 50 | - */ | |
| 51 | - public function __construct(Filesystem $files, Migrator $migrator) | |
| 52 | -    { | |
| 53 | - parent::__construct(); | |
| 54 | - $this->migrator = $migrator; | |
| 55 | - $this->files = $files; | |
| 56 | - } | |
| 57 | - | |
| 58 | - /** | |
| 59 | - * Fire the command. (Compatibility for < 5.5). | |
| 60 | - */ | |
| 61 | - public function fire() | |
| 62 | -    { | |
| 63 | - $this->handle(); | |
| 64 | - } | |
| 65 | - | |
| 66 | - /** | |
| 67 | - * Create date folder structure and move migrations into. | |
| 68 | - * | |
| 69 | - * @return void | |
| 70 | - */ | |
| 71 | - public function handle() | |
| 72 | -    { | |
| 73 | - $this->basePath = $this->getMigrationPath(); | |
| 74 | - $migrations = $this->migrator->getMigrationFiles($this->basePath); | |
| 75 | - $count = count($migrations); | |
| 76 | - | |
| 77 | -        if ($count == 0) { | |
| 78 | -            $this->comment('No migrations to move'); | |
| 79 | - | |
| 80 | - return; | |
| 81 | - } | |
| 82 | - | |
| 83 | -        foreach ($migrations as $migration_name => $migration_path) { | |
| 84 | - $datePath = $this->migrator->getDateFolderStructure($migration_name); | |
| 85 | - // Move the migration into base migration folder | |
| 86 | - $this->files->move($this->basePath.'/'.$datePath.$migration_name.'.php', $this->basePath.'/'.$migration_name.'.php'); | |
| 87 | - } | |
| 88 | - | |
| 89 | -        $this->info('Migrations disorganised successfully ('.$count.' migrations moved)'); | |
| 90 | - $this->cleanup(); | |
| 91 | - } | |
| 92 | - | |
| 93 | - /** | |
| 94 | - * Decide whether or not to delete directories. | |
| 95 | - * | |
| 96 | - * @return void | |
| 97 | - */ | |
| 98 | - public function cleanup() | |
| 99 | -    { | |
| 100 | -        if ($this->option('force')) { | |
| 101 | - $this->deleteDirs(); | |
| 102 | -        } elseif ($this->confirm('Delete all subdirectories in migrations folder?', true)) { | |
| 103 | - $this->deleteDirs(); | |
| 104 | - } | |
| 105 | - } | |
| 106 | - | |
| 107 | - /** | |
| 108 | - * Delete subdirectories in the migrations folder. | |
| 109 | - * | |
| 110 | - * @return void | |
| 111 | - */ | |
| 112 | - public function deleteDirs() | |
| 113 | -    { | |
| 114 | - $dirs = $this->files->directories($this->basePath); | |
| 115 | - | |
| 116 | -        foreach ($dirs as $dir) { | |
| 117 | - $this->files->deleteDirectory($dir); | |
| 118 | - } | |
| 119 | - | |
| 120 | -        $this->info('Subdirectories deleted'); | |
| 121 | - } | |
| 122 | - | |
| 123 | - /** | |
| 124 | - * Get the console command options. | |
| 125 | - * | |
| 126 | - * @return array | |
| 127 | - */ | |
| 128 | - protected function getOptions() | |
| 129 | -    { | |
| 130 | - return [ | |
| 131 | - ['force', null, InputOption::VALUE_NONE, 'Force the operation to delete migration folder subdirectories without prompt.'], | |
| 132 | - ]; | |
| 133 | - } | |
| 12 | + /** | |
| 13 | + * The console command name. | |
| 14 | + * | |
| 15 | + * @var string | |
| 16 | + */ | |
| 17 | + protected $name = 'migrate:disorganise'; | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * The console command description. | |
| 21 | + * | |
| 22 | + * @var string | |
| 23 | + */ | |
| 24 | + protected $description = 'Move migrations from a yyyy/mm folder structure back to the base migrations folder'; | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * The migrator instance. | |
| 28 | + * | |
| 29 | + * @var \Jaybizzle\MigrationsOrganiser\Migrator | |
| 30 | + */ | |
| 31 | + protected $migrator; | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * The filesystem instance. | |
| 35 | + * | |
| 36 | + * @var \Illuminate\Filesystem\Filesystem | |
| 37 | + */ | |
| 38 | + protected $files; | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * The basePath for the migrations. | |
| 42 | + */ | |
| 43 | + protected $basePath; | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * Create a new migrator instance. | |
| 47 | + * | |
| 48 | + * @param \Illuminate\Filesystem\Filesystem $files | |
| 49 | + * @param \Illuminate\Database\Migrations\Migrator $migrator | |
| 50 | + */ | |
| 51 | + public function __construct(Filesystem $files, Migrator $migrator) | |
| 52 | +	{ | |
| 53 | + parent::__construct(); | |
| 54 | + $this->migrator = $migrator; | |
| 55 | + $this->files = $files; | |
| 56 | + } | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * Fire the command. (Compatibility for < 5.5). | |
| 60 | + */ | |
| 61 | + public function fire() | |
| 62 | +	{ | |
| 63 | + $this->handle(); | |
| 64 | + } | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * Create date folder structure and move migrations into. | |
| 68 | + * | |
| 69 | + * @return void | |
| 70 | + */ | |
| 71 | + public function handle() | |
| 72 | +	{ | |
| 73 | + $this->basePath = $this->getMigrationPath(); | |
| 74 | + $migrations = $this->migrator->getMigrationFiles($this->basePath); | |
| 75 | + $count = count($migrations); | |
| 76 | + | |
| 77 | +		if ($count == 0) { | |
| 78 | +			$this->comment('No migrations to move'); | |
| 79 | + | |
| 80 | + return; | |
| 81 | + } | |
| 82 | + | |
| 83 | +		foreach ($migrations as $migration_name => $migration_path) { | |
| 84 | + $datePath = $this->migrator->getDateFolderStructure($migration_name); | |
| 85 | + // Move the migration into base migration folder | |
| 86 | + $this->files->move($this->basePath.'/'.$datePath.$migration_name.'.php', $this->basePath.'/'.$migration_name.'.php'); | |
| 87 | + } | |
| 88 | + | |
| 89 | +		$this->info('Migrations disorganised successfully ('.$count.' migrations moved)'); | |
| 90 | + $this->cleanup(); | |
| 91 | + } | |
| 92 | + | |
| 93 | + /** | |
| 94 | + * Decide whether or not to delete directories. | |
| 95 | + * | |
| 96 | + * @return void | |
| 97 | + */ | |
| 98 | + public function cleanup() | |
| 99 | +	{ | |
| 100 | +		if ($this->option('force')) { | |
| 101 | + $this->deleteDirs(); | |
| 102 | +		} elseif ($this->confirm('Delete all subdirectories in migrations folder?', true)) { | |
| 103 | + $this->deleteDirs(); | |
| 104 | + } | |
| 105 | + } | |
| 106 | + | |
| 107 | + /** | |
| 108 | + * Delete subdirectories in the migrations folder. | |
| 109 | + * | |
| 110 | + * @return void | |
| 111 | + */ | |
| 112 | + public function deleteDirs() | |
| 113 | +	{ | |
| 114 | + $dirs = $this->files->directories($this->basePath); | |
| 115 | + | |
| 116 | +		foreach ($dirs as $dir) { | |
| 117 | + $this->files->deleteDirectory($dir); | |
| 118 | + } | |
| 119 | + | |
| 120 | +		$this->info('Subdirectories deleted'); | |
| 121 | + } | |
| 122 | + | |
| 123 | + /** | |
| 124 | + * Get the console command options. | |
| 125 | + * | |
| 126 | + * @return array | |
| 127 | + */ | |
| 128 | + protected function getOptions() | |
| 129 | +	{ | |
| 130 | + return [ | |
| 131 | + ['force', null, InputOption::VALUE_NONE, 'Force the operation to delete migration folder subdirectories without prompt.'], | |
| 132 | + ]; | |
| 133 | + } | |
| 134 | 134 | } |