1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Acacha\AdminLTETemplateLaravel\Console; |
4
|
|
|
|
5
|
|
|
use Acacha\AdminLTETemplateLaravel\Exceptions\SpatieMenuAlreadyExists; |
6
|
|
|
use Acacha\AdminLTETemplateLaravel\Facades\AdminLTE; |
7
|
|
|
use Illuminate\Console\Command; |
8
|
|
|
use Illuminate\Filesystem\Filesystem; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class AdminLTEMenu. |
12
|
|
|
*/ |
13
|
|
|
class AdminLTEMenu extends Command |
14
|
|
|
{ |
15
|
|
|
use Installable; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* The filesystem instance. |
19
|
|
|
* |
20
|
|
|
* @var \Illuminate\Filesystem\Filesystem |
21
|
|
|
*/ |
22
|
|
|
protected $files; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* The name and signature of the console command. |
26
|
|
|
*/ |
27
|
|
|
protected $signature = 'adminlte-laravel:menu {--f|force : Force overwrite of files}'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* The console command description. |
31
|
|
|
* |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected $description = 'Replaces sidebar view with a sidebar using spatie/laravel-menu menu'; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Force overwrite of files. |
38
|
|
|
* |
39
|
|
|
* @var bool |
40
|
|
|
*/ |
41
|
|
|
protected $force = false; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Create a new command instance. |
45
|
|
|
* |
46
|
|
|
* @param \Illuminate\Filesystem\Filesystem $files |
47
|
|
|
* |
48
|
|
|
*/ |
49
|
|
|
public function __construct(Filesystem $files) |
50
|
|
|
{ |
51
|
|
|
parent::__construct(); |
52
|
|
|
$this->files = $files; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Execute the console command. |
57
|
|
|
*/ |
58
|
|
|
public function handle() |
59
|
|
|
{ |
60
|
|
|
$this->processOptions(); |
61
|
|
|
$this->checkIfSpatieMenuAlreadyInstalled(); |
62
|
|
|
$this->installSpatieMenu(); |
63
|
|
|
$this->publishSpatieMenu(); |
64
|
|
|
$this->publishSpatieMenuConfig(); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Check if spatie menu is already installed. |
69
|
|
|
* |
70
|
|
|
* @throws SpatieMenuAlreadyExists |
71
|
|
|
*/ |
72
|
|
|
protected function checkIfSpatieMenuAlreadyInstalled() |
73
|
|
|
{ |
74
|
|
|
if ((app()->getProvider('Spatie\Menu\Laravel\MenuServiceProvider')) && ! $this->force) { |
75
|
|
|
throw new SpatieMenuAlreadyExists(); |
76
|
|
|
} |
77
|
|
|
return; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Install spatie/laravel-menu. |
82
|
|
|
*/ |
83
|
|
|
protected function installSpatieMenu() |
84
|
|
|
{ |
85
|
|
|
passthru('llum package laravel-menu'); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Process options before running command. |
90
|
|
|
*/ |
91
|
|
|
protected function processOptions() |
92
|
|
|
{ |
93
|
|
|
$this->force = $this->option('force'); |
|
|
|
|
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Publish sidebar with spatie menu |
98
|
|
|
*/ |
99
|
|
|
protected function publishSpatieMenu() |
100
|
|
|
{ |
101
|
|
|
$this->install(AdminLTE::spatieMenu()); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Publish spatie menu config |
106
|
|
|
*/ |
107
|
|
|
protected function publishSpatieMenuConfig() |
108
|
|
|
{ |
109
|
|
|
$this->install(AdminLTE::menu()); |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..