Completed
Push — master ( 3dec05...c1872b )
by wen
03:33
created

InstallCommand::executeCommand()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 15
rs 9.4285
cc 3
eloc 10
nc 2
nop 1
1
<?php
2
3
namespace Sco\Admin\Console;
4
5
use Illuminate\Console\Command;
6
use Symfony\Component\Process\Exception\ProcessFailedException;
7
use Symfony\Component\Process\ExecutableFinder;
8
use Symfony\Component\Process\Process;
9
10
class InstallCommand extends Command
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'admin:install';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Install Sco Admin Package(publish/migrate).';
25
26
    /**
27
     * Create a new command instance.
28
     *
29
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
30
     */
31
    public function __construct()
32
    {
33
        parent::__construct();
34
    }
35
36
    /**
37
     * Execute the console command.
38
     *
39
     * @return mixed
40
     */
41
    public function handle()
42
    {
43
        $this->line('');
44
        $this->line('************************');
45
        $this->line('  Welcome to Sco Admin  ');
46
        $this->line('************************');
47
48
        $this->publish();
49
        $this->migrate();
50
51
        $this->info('Successfully Installed Sco Admin!');
52
    }
53
54
    protected function publish()
55
    {
56
        $this->line('Publish Resources');
57
        $this->line('');
58
        $this->call('vendor:publish', [
59
            '--provider' => 'Sco\Admin\Providers\AdminServiceProvider',
60
            '--force'    => true,
61
        ]);
62
    }
63
64
    protected function migrate()
65
    {
66
        $this->line('Running Database Migrations');
67
        $this->line('');
68
        $this->call('migrate', ['--force' => true]);
69
        $this->line('');
70
71
        $this->line('Seeding database');
72
        $this->line('');
73
        $this->call('db:seed', [
74
            '--force' => true,
75
            '--class' => \AdminTableSeeder::class,
76
        ]);
77
        $this->line('');
78
79
    }
80
}
81