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() |
|
|
|
|
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() |
|
|
|
|
64
|
|
|
{ |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
private function feedCurrencies(){ |
|
|
|
|
69
|
|
|
|
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
private function installTicketStatuses() |
|
|
|
|
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
|
|
|
|