1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Providers; |
4
|
|
|
|
5
|
|
|
use App\Http\Terranet\Administrator\Dashboard\BlankPanel; |
6
|
|
|
use App\Http\Terranet\Administrator\Dashboard\DatabasePanel; |
7
|
|
|
use App\Http\Terranet\Administrator\Dashboard\MembersPanel; |
8
|
|
|
use Illuminate\Support\ServiceProvider; |
9
|
|
|
use Pingpong\Menus\Menu; |
10
|
|
|
use Pingpong\Menus\MenuBuilder; |
11
|
|
|
use Pingpong\Menus\MenuItem; |
12
|
|
|
use Terranet\Administrator\Architect; |
13
|
|
|
use Terranet\Administrator\Contracts\Module\Navigable; |
14
|
|
|
use Terranet\Administrator\Dashboard\Manager; |
15
|
|
|
use Terranet\Administrator\Dashboard\Row; |
16
|
|
|
use Terranet\Options\Manager as OptionsManager; |
|
|
|
|
17
|
|
|
|
18
|
|
|
class AdminServiceProvider extends ServiceProvider |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Dashboard panels registration. |
22
|
|
|
* |
23
|
|
|
* @param Manager $dashboard |
24
|
|
|
* @return Manager |
25
|
|
|
*/ |
26
|
|
|
protected function dashboard(Manager $dashboard) |
27
|
|
|
{ |
28
|
|
|
return $dashboard |
29
|
|
|
->row(static function (Row $row) { |
30
|
|
|
$row->panel(new BlankPanel())->setWidth(12); |
31
|
|
|
}) |
32
|
|
|
->row(static function (Row $row) { |
33
|
|
|
$row->panel(new MembersPanel())->setWidth(6); |
34
|
|
|
$row->panel(new DatabasePanel())->setWidth(6); |
35
|
|
|
}); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param Menu $navigation |
40
|
|
|
* @return Menu |
41
|
|
|
*/ |
42
|
|
|
protected function navigation(Menu $navigation) |
43
|
|
|
{ |
44
|
|
|
$this->initSidebar($navigation) |
45
|
|
|
->initToolbar($navigation); |
46
|
|
|
|
47
|
|
|
return $navigation; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Register services. |
52
|
|
|
* |
53
|
|
|
* @return void |
54
|
|
|
*/ |
55
|
|
|
public function register() |
56
|
|
|
{ |
57
|
|
|
$this->app->singleton('scaffold.dashboard', function () { |
58
|
|
|
return $this->dashboard(new Manager()); |
59
|
|
|
}); |
60
|
|
|
|
61
|
|
|
$this->app->singleton('scaffold.navigation', function ($app) { |
62
|
|
|
return $this->navigation(new Menu($app['view'], $app['config'])); |
63
|
|
|
}); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Bootstrap any application services. |
68
|
|
|
* |
69
|
|
|
* @return void |
70
|
|
|
*/ |
71
|
|
|
public function boot() |
72
|
|
|
{ |
73
|
|
|
$this->routes(); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Register AdminArchitect routes. |
78
|
|
|
*/ |
79
|
|
|
protected function routes() |
80
|
|
|
{ |
81
|
|
|
Architect::routes() |
82
|
|
|
->withAuthenticationRoutes() |
83
|
|
|
->withTranslationRoutes() |
84
|
|
|
->withMediaRoutes() |
85
|
|
|
->withSettingRoutes() |
86
|
|
|
->withExtraRoutes(function () { |
87
|
|
|
$path = base_path('routes/admin.php'); |
|
|
|
|
88
|
|
|
|
89
|
|
|
if (file_exists($path)) { |
90
|
|
|
$this->loadRoutesFrom($path); |
91
|
|
|
} |
92
|
|
|
}); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param Menu $navigation |
97
|
|
|
* @return AdminServiceProvider |
98
|
|
|
*/ |
99
|
|
|
protected function initSidebar(Menu $navigation): self |
100
|
|
|
{ |
101
|
|
|
$navigation->create(Navigable::MENU_SIDEBAR, static function (MenuBuilder $sidebar) { |
102
|
|
|
$this->withDashboard($sidebar); |
103
|
|
|
|
104
|
|
|
// Create "resources" group |
105
|
|
|
$sidebar->dropdown(trans('administrator::module.groups.resources'), static function (MenuItem $sub) { |
|
|
|
|
106
|
|
|
// $sub->route(); |
107
|
|
|
}, 2, ['id' => 'groups', 'icon' => 'fa fa-qrcode']); |
108
|
|
|
}); |
109
|
|
|
|
110
|
|
|
return $this; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @param Menu $navigation |
115
|
|
|
* @return AdminServiceProvider |
116
|
|
|
*/ |
117
|
|
|
protected function initToolbar(Menu $navigation): self |
118
|
|
|
{ |
119
|
|
|
$navigation->create(Navigable::MENU_TOOLS, function (MenuBuilder $tools) { |
120
|
|
|
$this->withMedia($tools) |
121
|
|
|
->withSettings($tools) |
122
|
|
|
->withTranslations($tools); |
123
|
|
|
|
124
|
|
|
$tools->url( |
125
|
|
|
route('scaffold.logout'), |
|
|
|
|
126
|
|
|
trans('administrator::buttons.logout'), |
|
|
|
|
127
|
|
|
100, |
128
|
|
|
['icon' => 'fa fa-mail-forward'] |
129
|
|
|
); |
130
|
|
|
}); |
131
|
|
|
|
132
|
|
|
return $this; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @param MenuBuilder $sidebar |
137
|
|
|
* @return $this |
138
|
|
|
*/ |
139
|
|
|
public function withDashboard(MenuBuilder $sidebar): self |
140
|
|
|
{ |
141
|
|
|
$sidebar->route('scaffold.dashboard', trans('administrator::module.dashboard'), [], 1, [ |
|
|
|
|
142
|
|
|
'id' => 'dashboard', |
143
|
|
|
'icon' => 'fa fa-home', |
144
|
|
|
'active' => str_is(request()->route()->getName(), 'scaffold.dashboard'), |
|
|
|
|
145
|
|
|
]); |
146
|
|
|
|
147
|
|
|
return $this; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @param MenuBuilder $tools |
152
|
|
|
* @return $this |
153
|
|
|
*/ |
154
|
|
|
protected function withMedia(MenuBuilder $tools): self |
155
|
|
|
{ |
156
|
|
|
if (config('administrator.file_manager.enabled')) { |
|
|
|
|
157
|
|
|
$tools->url( |
158
|
|
|
route('scaffold.media'), |
|
|
|
|
159
|
|
|
trans('administrator::buttons.media'), |
|
|
|
|
160
|
|
|
1, |
161
|
|
|
['icon' => 'fa fa-file-text-o'] |
162
|
|
|
); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
return $this; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* @param MenuBuilder $tools |
170
|
|
|
* @return $this |
171
|
|
|
*/ |
172
|
|
|
protected function withSettings(MenuBuilder $tools): self |
173
|
|
|
{ |
174
|
|
|
if (config('administrator.settings.enabled') && class_exists(OptionsManager::class, true)) { |
|
|
|
|
175
|
|
|
$tools->url( |
176
|
|
|
route('scaffold.settings.edit'), |
|
|
|
|
177
|
|
|
trans('administrator::module.resources.settings'), |
|
|
|
|
178
|
|
|
2, |
179
|
|
|
['icon' => 'fa fa-gears'] |
180
|
|
|
); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
return $this; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @param MenuBuilder $tools |
188
|
|
|
* @return $this |
189
|
|
|
*/ |
190
|
|
|
protected function withTranslations(MenuBuilder $tools): self |
191
|
|
|
{ |
192
|
|
|
if (config('administrator.translations.enabled')) { |
|
|
|
|
193
|
|
|
$tools->url( |
194
|
|
|
route('scaffold.translations.index'), |
|
|
|
|
195
|
|
|
trans('administrator::buttons.translations'), |
|
|
|
|
196
|
|
|
3, |
197
|
|
|
['icon' => 'fa fa-globe'] |
198
|
|
|
); |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
return $this; |
202
|
|
|
} |
203
|
|
|
} |
204
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths