Last active
June 16, 2017 00:02
-
-
Save Gkiokan/ecfb6ed9ca7102c4e9d5ea260fcd3339 to your computer and use it in GitHub Desktop.
Laravel BaseCommand Extension for Modules Migration Status Commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Illuminate\Database\Console\Migrations; | |
use Illuminate\Console\Command; | |
use Nwidart\Modules\Facades\Module; | |
class BaseCommand extends Command | |
{ | |
/** | |
* Get all of the migration paths. | |
* | |
* @return array | |
*/ | |
protected function getMigrationPaths() | |
{ | |
// 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) { | |
return $this->laravel->basePath().'/'.$path; | |
})->all(); | |
} | |
// Array of Modules | |
$modules = ['Magic', 'ui', 'ytc', 'core']; | |
// Add each of them to the Migration paths | |
foreach($modules as $module) | |
$this->laravel->basePath() . '/Modules/' . $module .'/Database/Migrations'; | |
return array_merge( | |
[$this->getMigrationPath()], $this->migrator->paths(), $modules | |
); | |
} | |
/** | |
* Get the path to the migration directory. | |
* | |
* @return string | |
*/ | |
protected function getMigrationPath() | |
{ | |
return $this->laravel->databasePath().DIRECTORY_SEPARATOR.'migrations'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment