Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 23, 2018
1 parent 0671f31 commit 98842da
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 20 deletions.
18 changes: 14 additions & 4 deletions src/Illuminate/Database/Console/Migrations/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ class BaseCommand extends Command
*/
protected function getMigrationPaths()
{
$realpath = $this->input->hasOption('realpath') && $this->option('realpath');

// Here, we will check to see if a path option has been defined. If it has we will
// use the path relative to the root of the installation folder so our database
// migrations may be run for any customized path from within the application.
if ($this->input->hasOption('path') && $this->option('path')) {
return collect($this->option('path'))->map(function ($path) use ($realpath) {
return $realpath ? $path : $this->laravel->basePath().'/'.$path;
return collect($this->option('path'))->map(function ($path) {
return ! $this->usingRealPath()
? $this->laravel->basePath().'/'.$path
: $path;
})->all();
}

Expand All @@ -29,6 +29,16 @@ protected function getMigrationPaths()
);
}

/**
* Determine if the given path(s) are pre-resolved "real" paths.
*
* @return bool
*/
protected function usingRealPath()
{
return $this->input->hasOption('realpath') && $this->option('realpath');
}

/**
* Get the path to the migration directory.
*
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Console/Migrations/FreshCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ protected function getOptions()

['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],

['path', null, InputOption::VALUE_OPTIONAL, 'The path of migrations files to be executed.'],
['path', null, InputOption::VALUE_OPTIONAL, 'The path to the migrations files to be executed.'],

['realpath', null, InputOption::VALUE_NONE, 'Mark the given migration path(s) as realpath.'],
['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre-resolved absolute paths.'],

['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'],

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Console/Migrations/MigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class MigrateCommand extends BaseCommand
*/
protected $signature = 'migrate {--database= : The database connection to use.}
{--force : Force the operation to run when in production.}
{--path= : The path of migrations files to be executed.}
{--realpath : Mark the given migration path(s) as realpath.}
{--path= : The path to the migrations files to be executed.}
{--realpath : Indicate any provided migration file paths are pre-resolved absolute paths.}
{--pretend : Dump the SQL queries that would be run.}
{--seed : Indicates if the seed task should be re-run.}
{--step : Force the migrations to be run so they can be rolled back individually.}';
Expand Down
18 changes: 14 additions & 4 deletions src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MigrateMakeCommand extends BaseCommand
{--create= : The table to be created.}
{--table= : The table to migrate.}
{--path= : The location where the migration file should be created.}
{--realpath : Mark the given migration path as realpath.}';
{--realpath : Indicate any provided migration file paths are pre-resolved absolute paths.}';

/**
* The console command description.
Expand Down Expand Up @@ -124,11 +124,21 @@ protected function writeMigration($name, $table, $create)
protected function getMigrationPath()
{
if (! is_null($targetPath = $this->input->getOption('path'))) {
$realpath = $this->input->hasOption('realpath') && $this->option('realpath');

return $realpath ? $targetPath : $this->laravel->basePath().'/'.$targetPath;
return ! $this->usingRealPath()
? $this->laravel->basePath().'/'.$targetPath
: $targetPath;
}

return parent::getMigrationPath();
}

/**
* Determine if the given path(s) are pre-resolved "real" paths.
*
* @return bool
*/
protected function usingRealPath()
{
return $this->input->hasOption('realpath') && $this->option('realpath');
}
}
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Console/Migrations/RefreshCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ protected function getOptions()

['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],

['path', null, InputOption::VALUE_OPTIONAL, 'The path of migrations files to be executed.'],
['path', null, InputOption::VALUE_OPTIONAL, 'The path to the migrations files to be executed.'],

['realpath', null, InputOption::VALUE_NONE, 'Mark the given migration path(s) as realpath.'],
['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre-resolved absolute paths.'],

['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'],

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Console/Migrations/ResetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ protected function getOptions()

['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],

['path', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The path(s) of migrations files to be executed.'],
['path', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The path(s) to the migrations files to be executed.'],

['realpath', null, InputOption::VALUE_NONE, 'Mark the given migration path(s) as realpath.'],
['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre-resolved absolute paths.'],

['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ protected function getOptions()

['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],

['path', null, InputOption::VALUE_OPTIONAL, 'The path of migrations files to be executed.'],
['path', null, InputOption::VALUE_OPTIONAL, 'The path to the migrations files to be executed.'],

['realpath', null, InputOption::VALUE_NONE, 'Mark the given migration path(s) as realpath.'],
['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre-resolved absolute paths.'],

['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'],

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Console/Migrations/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ protected function getOptions()
return [
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'],

['path', null, InputOption::VALUE_OPTIONAL, 'The path of migrations files to use.'],
['path', null, InputOption::VALUE_OPTIONAL, 'The path to the migrations files to use.'],

['realpath', null, InputOption::VALUE_NONE, 'Mark the given migration path(s) as realpath.'],
['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre-resolved absolute paths.'],
];
}
}

0 comments on commit 98842da

Please sign in to comment.