Completed
Push — main ( ef1f4c...49038c )
by Emmanuel
01:15
created

EticketInstall::feedCurrencies()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * Author: Emmanuel Paul Mnzava
5
 * Twitter: @epmnzava
6
 * Github:https://github.com/dbrax/eticket
7
 * Email: [email protected]
8
 * 
9
 */
10
11
namespace Epmnzava\Eticket\Console;
12
13
use Illuminate\Console\Command;
14
use Illuminate\Support\Facades\File;
15
16
class EticketInstall extends Command
17
{
18
    protected $signature = 'eticket:install';
19
20
    protected $description = 'Command to install package';
21
22
    public function handle()
23
    {
24
        $this->info('Begining to install ticket package  🤙 🤙 🤙');
25
26
        if (!$this->configExists('eticket.php')) {
27
            $this->publishConfiguration();
28
            $this->info('Published configuration  🤙 🤙 🤙');
29
30
            //check if migrations are not available then migrate
31
            //publish migrations ..
32
33
            //then 
34
35
36
        } else {
37
            if ($this->shouldOverwriteConfig()) {
38
                $this->info('Overwriting configuration file...');
39
                $this->publishConfiguration($force = true);
40
            } else {
41
                $this->info('Existing configuration was not overwritten  🤙 🤙 🤙');
42
            }
43
        }
44
45
46
47
        $this->info('End of installing package ');
48
    }
49
50
    private function publishMigrations()
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
51
    { 
52
        
53
        $params = [
54
        '--provider' => "Epmnzava\Eticket\EticketServiceProvider",
55
        '--tag' => "migration"
56
    ];
57
58
    $this->call('vendor:publish', $params);
59
60
61
    }
62
63
    private function feedTicketStatus()
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
64
    {
65
    }
66
67
68
    private function feedCurrencies(){
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
69
        
70
    }
71
72
    private function installTicketStatuses()
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
73
    {
74
    }
75
    private function configExists($fileName)
76
    {
77
        return File::exists(config_path($fileName));
78
    }
79
80
    private function shouldOverwriteConfig()
81
    {
82
        return $this->confirm(
83
            'Config file already exists. Do you want to overwrite it?',
84
            false
85
        );
86
    }
87
88
    private function publishConfiguration($forcePublish = false)
89
    {
90
        $params = [
91
            '--provider' => "Epmnzava\Eticket\EticketServiceProvider",
92
            '--tag' => "config"
93
        ];
94
95
        if ($forcePublish === true) {
96
            $params['--force'] = '';
97
        }
98
99
100
101
        $this->call('vendor:publish', $params);
102
    }
103
}
104