Completed
Push — master ( 15e02a...758c52 )
by Nicolas
05:13
created

PublishMigrationCommand::publish()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 0
cts 6
cp 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Nwidart\Modules\Commands;
4
5
use Illuminate\Console\Command;
6
use Nwidart\Modules\Publishing\MigrationPublisher;
7
use Symfony\Component\Console\Input\InputArgument;
8
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
    public function fire()
31
    {
32
        if ($name = $this->argument('module')) {
33
            $module = $this->laravel['modules']->findOrFail($name);
34
35
            $this->publish($module);
36
37
            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
    public function publish($module)
51
    {
52
        with(new MigrationPublisher($module))
53
            ->setRepository($this->laravel['modules'])
54
            ->setConsole($this)
55
            ->publish();
56
    }
57
58
    /**
59
     * Get the console command arguments.
60
     *
61
     * @return array
62
     */
63 16
    protected function getArguments()
64
    {
65
        return array(
66 16
            array('module', InputArgument::OPTIONAL, 'The name of module being used.'),
67 16
        );
68
    }
69
}
70