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

SetupCommand   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 5
Bugs 0 Features 0
Metric Value
c 5
b 0
f 0
dl 0
loc 97
ccs 0
cts 41
cp 0
rs 10
wmc 7
lcom 1
cbo 2

5 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 8 2
A setup() 0 6 1
A publishAllModules() 0 11 1
A refreshMigrations() 0 9 1
A seedAllModules() 0 15 2
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