|
1
|
|
|
<?php namespace Serverfireteam\Panel\Commands; |
|
2
|
|
|
|
|
3
|
|
|
use Illuminate\Console\Command; |
|
4
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
5
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
6
|
|
|
|
|
7
|
|
|
class PanelCommand extends Command { |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* The console command name. |
|
11
|
|
|
* |
|
12
|
|
|
* @var string holds the name of the command |
|
13
|
|
|
*/ |
|
14
|
|
|
protected $name = 'panel:install'; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* The console command description. |
|
18
|
|
|
* |
|
19
|
|
|
* @var string holds the description of the command |
|
20
|
|
|
*/ |
|
21
|
|
|
protected $description = 'Installs Panel migrations, configs, views and assets.'; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Create a new command instance. |
|
25
|
|
|
* |
|
26
|
|
|
*/ |
|
27
|
|
|
public function __construct() |
|
28
|
|
|
{ |
|
29
|
|
|
parent::__construct(); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Execute the console command. |
|
34
|
|
|
* |
|
35
|
|
|
*/ |
|
36
|
|
|
public function handle() |
|
37
|
|
|
{ |
|
38
|
|
|
$this->info(' [ Welcome to ServerFireTeam Panel Installation ] '); |
|
39
|
|
|
|
|
40
|
|
|
$this->info('** publishing elfinder assets'); |
|
41
|
|
|
$this->call('elfinder:publish'); |
|
42
|
|
|
|
|
43
|
|
|
$this->info('** publishing panel assets'); |
|
44
|
|
|
$this->call('vendor:publish', [ |
|
45
|
|
|
'--tag' => 'public', |
|
46
|
|
|
'--quiet' => null |
|
47
|
|
|
//'--force' => 1 |
|
48
|
|
|
]); |
|
49
|
|
|
$this->info('** publishing panel config'); |
|
50
|
|
|
$this->call('vendor:publish', [ |
|
51
|
|
|
'--tag' => 'config', |
|
52
|
|
|
'--quiet' => null |
|
53
|
|
|
//'--force' => 1 |
|
54
|
|
|
]); |
|
55
|
|
|
$this->info('** publishing panel views'); |
|
56
|
|
|
$this->call('vendor:publish', [ |
|
57
|
|
|
'--tag' => 'views', |
|
58
|
|
|
'--quiet' => null |
|
59
|
|
|
//'--force' => 1 |
|
60
|
|
|
]); |
|
61
|
|
|
|
|
62
|
|
|
$this->call('migrate', array('--path' => 'vendor/serverfireteam/panel/src/database/migrations')); |
|
63
|
|
|
|
|
64
|
|
|
$this->call('db:seed', array('--class' => '\Serverfireteam\Panel\LinkSeeder')); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Get the console command arguments. |
|
69
|
|
|
* |
|
70
|
|
|
* @return array |
|
71
|
|
|
*/ |
|
72
|
|
|
protected function getArguments() |
|
73
|
|
|
{ |
|
74
|
|
|
return []; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Get the console command options. |
|
79
|
|
|
* |
|
80
|
|
|
* @return array |
|
81
|
|
|
*/ |
|
82
|
|
|
protected function getOptions() |
|
83
|
|
|
{ |
|
84
|
|
|
return []; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Copy specific directories to destination |
|
89
|
|
|
* @param $destination |
|
90
|
|
|
* @return bool |
|
91
|
|
|
* @throws \ReflectionException |
|
92
|
|
|
*/ |
|
93
|
|
|
protected function copyFiles($destination) |
|
94
|
|
|
{ |
|
95
|
|
|
$result = true; |
|
96
|
|
|
$directories = array('public'); |
|
97
|
|
|
$root_path = $this->getRootPath(); |
|
98
|
|
|
foreach($directories as $dir){ |
|
99
|
|
|
$path = $root_path.'/'.$dir; |
|
100
|
|
|
$success = $this->files->copyDirectory($path, $destination); |
|
101
|
|
|
$result = $success && $result; |
|
102
|
|
|
} |
|
103
|
|
|
return $result; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Find the root path from the vendor dir. |
|
108
|
|
|
* @return bool|string |
|
109
|
|
|
* @throws \ReflectionException |
|
110
|
|
|
*/ |
|
111
|
|
|
protected function getRootPath() |
|
112
|
|
|
{ |
|
113
|
|
|
$reflector = new \ReflectionClass('serverfireteam_panel'); |
|
114
|
|
|
$path = realpath(dirname($reflector->getFileName()) . '/..'); |
|
115
|
|
|
return $path; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
} |
|
119
|
|
|
|