Completed
Push — master ( a629b9...125cb7 )
by ARCANEDEV
11:53
created

InstallCommand::refreshMigrations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 9.6666
1
<?php namespace Arcanesoft\Foundation\Console;
2
3
use Arcanesoft\Foundation\Seeds\DatabaseSeeder;
4
5
/**
6
 * Class     InstallCommand
7
 *
8
 * @package  Arcanesoft\Foundation\Console
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class InstallCommand extends Command
12
{
13
    /* -----------------------------------------------------------------
14
     |  Properties
15
     | -----------------------------------------------------------------
16
     */
17
    /**
18
     * The name and signature of the console command.
19
     *
20
     * @var string
21
     */
22
    protected $signature = 'foundation:install';
23
24
    /**
25
     * The console command description.
26
     *
27
     * @var string
28
     */
29
    protected $description = 'Foundation install command.';
30
31
    /* -----------------------------------------------------------------
32
     |  Main Methods
33
     | -----------------------------------------------------------------
34
     */
35
    /**
36
     * Execute the console command.
37
     */
38
    public function handle()
39
    {
40
        $this->arcanesoftHeader();
41
42
        if ($this->confirm('Do you wish to reset the application ? [y|N]')) {
43
            $this->setup();
44
        }
45
    }
46
47
    /**
48
     * Run the setup.
49
     */
50
    private function setup()
51
    {
52
        $this->publishAllModules();
53
        $this->refreshMigrations();
54
        $this->installModules();
55
    }
56
57
    /* -----------------------------------------------------------------
58
     |  Other Methods
59
     | -----------------------------------------------------------------
60
     */
61
    /**
62
     * Publish all modules: configs, migrations, assets ...
63
     */
64
    private function publishAllModules()
65
    {
66
        $this->frame('Publishing all the modules files');
67
        $this->line('');
68
69
        $this->call('foundation:publish');
70
        $this->call('optimize');
71
72
        $this->comment('All files are published !');
73
        $this->line('');
74
    }
75
76
    /**
77
     * Refresh migrations.
78
     */
79
    private function refreshMigrations()
80
    {
81
        $this->frame('Refreshing all the migrations');
82
        $this->line('');
83
84
        $this->call('migrate:refresh');
85
86
        $this->line('');
87
    }
88
89
    /**
90
     * Seed all modules.
91
     */
92
    private function installModules()
93
    {
94
        foreach ($this->config()->get('arcanesoft.foundation.modules.commands.install', []) as $command) {
95
            $this->call($command);
96
        }
97
98
        $this->frame('Seeding the database');
99
        $this->line('');
100
101
        $this->call('db:seed', ['--class' => DatabaseSeeder::class]);
102
103
        $this->comment('Database seeded !');
104
        $this->line('');
105
    }
106
}
107