| 1 | <?php |
||
| 9 | class PublishMigrationCommand extends Command |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * The console command name. |
||
| 13 | * |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | protected $name = 'module:publish-migration'; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * The console command description. |
||
| 20 | * |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected $description = "Publish a module's migrations to the application"; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Execute the console command. |
||
| 27 | * |
||
| 28 | * @return mixed |
||
| 29 | */ |
||
| 30 | 1 | public function fire() |
|
| 31 | { |
||
| 32 | 1 | if ($name = $this->argument('module')) { |
|
| 33 | 1 | $module = $this->laravel['modules']->findOrFail($name); |
|
| 34 | |||
| 35 | 1 | $this->publish($module); |
|
| 36 | |||
| 37 | 1 | return; |
|
| 38 | } |
||
| 39 | |||
| 40 | foreach ($this->laravel['modules']->enabled() as $module) { |
||
| 41 | $this->publish($module); |
||
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Publish migration for the specified module. |
||
| 47 | * |
||
| 48 | * @param \Nwidart\Modules\Module $module |
||
| 49 | */ |
||
| 50 | 1 | public function publish($module) |
|
| 51 | { |
||
| 52 | 1 | with(new MigrationPublisher($module)) |
|
| 53 | 1 | ->setRepository($this->laravel['modules']) |
|
| 54 | 1 | ->setConsole($this) |
|
| 55 | 1 | ->publish(); |
|
| 56 | 1 | } |
|
| 57 | |||
| 58 | /** |
||
| 59 | * Get the console command arguments. |
||
| 60 | * |
||
| 61 | * @return array |
||
| 62 | */ |
||
| 63 | 20 | protected function getArguments() |
|
| 69 | } |
||
| 70 |