Completed
Push — master ( 96a0f4...96dd95 )
by ARCANEDEV
03:51
created

SetupCommand::setup()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

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 6
ccs 0
cts 6
cp 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 2
1
<?php namespace Arcanesoft\Foundation\Console;
2
3
use Arcanedev\Support\Bases\Command;
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
     * Display arcanesoft header.
49
     */
50
    private function arcanesoftHeader()
51
    {
52
        $this->comment('    ___    ____  _________    _   _____________ ____  ____________');
53
        $this->comment('   /   |  / __ \/ ____/   |  / | / / ____/ ___// __ \/ ____/_  __/');
54
        $this->comment('  / /| | / /_/ / /   / /| | /  |/ / __/  \__ \/ / / / /_    / /   ');
55
        $this->comment(' / ___ |/ _, _/ /___/ ___ |/ /|  / /___ ___/ / /_/ / __/   / /    ');
56
        $this->comment('/_/  |_/_/ |_|\____/_/  |_/_/ |_/_____//____/\____/_/     /_/     ');
57
        $this->line('');
58
59
        // Copyright
60
        $this->comment('Version ' . foundation()->version() . ' | 2015-2016 | Created by ARCANEDEV(c)');
61
        $this->line('');
62
    }
63
64
    /**
65
     * Run the setup.
66
     */
67
    private function setup()
68
    {
69
        $this->publishAllModules();
70
        $this->refreshMigrations();
71
        $this->seedAllModules();
72
    }
73
74
    /* ------------------------------------------------------------------------------------------------
75
     |  Other Functions
76
     | ------------------------------------------------------------------------------------------------
77
     */
78
    /**
79
     * Publish all modules : configs, migrations, assets ...
80
     */
81
    private function publishAllModules()
82
    {
83
        $this->frame('Publishing all the modules files');
84
        $this->line('');
85
86
        $this->call('foundation:publish');
87
        $this->call('optimize');
88
89
        $this->comment('All files are published !');
90
        $this->line('');
91
    }
92
93
    /**
94
     * Refresh migrations.
95
     */
96
    private function refreshMigrations()
97
    {
98
        $this->frame('Refreshing all the migrations');
99
        $this->line('');
100
101
        $this->call('migrate:refresh');
102
103
        $this->line('');
104
    }
105
106
    /**
107
     * Seed all modules.
108
     */
109
    private function seedAllModules()
110
    {
111
        $this->frame('Seeding the database');
112
        $this->line('');
113
114
        $this->call('auth:setup');
115
116
        $this->call('db:seed', [
117
            '--class' => \Arcanesoft\Foundation\Seeds\DatabaseSeeder::class
118
        ]);
119
120
        $this->comment('Database seeded !');
121
        $this->line('');
122
    }
123
}
124