Completed
Push — master ( 5c52b8...379248 )
by ARCANEDEV
03:49
created

SetupCommand::config()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
1
<?php namespace Arcanesoft\Foundation\Console;
2
3
use Arcanesoft\Foundation\Seeds\DatabaseSeeder;
4
5
/**
6
 * Class     SetupCommand
7
 *
8
 * @package  Arcanesoft\Foundation\Console
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class SetupCommand 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:setup';
23
24
    /**
25
     * The console command description.
26
     *
27
     * @var string
28
     */
29
    protected $description = 'Foundation setup command.';
30
31
    /* ------------------------------------------------------------------------------------------------
32
     |  Main Functions
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->seedAllModules();
55
    }
56
57
    /* ------------------------------------------------------------------------------------------------
58
     |  Other Functions
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 seedAllModules()
93
    {
94
        $this->frame('Seeding the database');
95
        $this->line('');
96
97
        $this->call('auth:setup');
98
        $this->call('db:seed', ['--class' => DatabaseSeeder::class]);
99
100
        $this->comment('Database seeded !');
101
        $this->line('');
102
103
        foreach ($this->config()->get('arcanesoft.foundation.modules.setup', []) as $setup) {
104
            $this->call($setup);
105
        }
106
    }
107
}
108