Completed
Push — master ( b3f9cd...9095db )
by wen
23:07
created

InstallCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 55
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 12 1
A publish() 0 8 1
A routes() 0 10 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
                    {--force : Overwrite existing files}';
19
20
    /**
21
     * The console command description.
22
     *
23
     * @var string
24
     */
25
    protected $description = 'Install Sco Admin Package.';
26
27
    /**
28
     * Execute the console command.
29
     *
30
     * @return mixed
31
     */
32
    public function handle()
33
    {
34
        $this->line('');
35
        $this->line('************************');
36
        $this->line('  Welcome to Sco Admin  ');
37
        $this->line('************************');
38
39
        $this->publish();
40
        $this->routes();
41
42
        $this->info('Successfully Installed Sco Admin!');
43
    }
44
45
    protected function publish()
46
    {
47
        $this->line('Publish Resources');
48
        $this->call('vendor:publish', [
49
            '--provider' => 'Sco\Admin\Providers\ResourcesServiceProvider',
50
            '--force'    => true,
51
        ]);
52
    }
53
54
    protected function routes()
55
    {
56
        file_put_contents(
57
            base_path('routes/web.php'),
58
            "\nAdmin::routes();",
59
            FILE_APPEND
60
        );
61
62
        $this->info('Routes generated successfully.');
63
    }
64
}
65