|
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
|
|
|
private function installTicketStatuses() |
|
|
|
|
|
|
68
|
|
|
{ |
|
69
|
|
|
} |
|
70
|
|
|
private function configExists($fileName) |
|
71
|
|
|
{ |
|
72
|
|
|
return File::exists(config_path($fileName)); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
private function shouldOverwriteConfig() |
|
76
|
|
|
{ |
|
77
|
|
|
return $this->confirm( |
|
78
|
|
|
'Config file already exists. Do you want to overwrite it?', |
|
79
|
|
|
false |
|
80
|
|
|
); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
private function publishConfiguration($forcePublish = false) |
|
84
|
|
|
{ |
|
85
|
|
|
$params = [ |
|
86
|
|
|
'--provider' => "Epmnzava\Eticket\EticketServiceProvider", |
|
87
|
|
|
'--tag' => "config" |
|
88
|
|
|
]; |
|
89
|
|
|
|
|
90
|
|
|
if ($forcePublish === true) { |
|
91
|
|
|
$params['--force'] = ''; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
|
|
95
|
|
|
|
|
96
|
|
|
$this->call('vendor:publish', $params); |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|