|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Pratiksh\Adminetic\Services; |
|
4
|
|
|
|
|
5
|
|
|
use Exception; |
|
6
|
|
|
use Illuminate\Support\Str; |
|
7
|
|
|
use Pratiksh\Adminetic\Traits\SidebarHelper; |
|
8
|
|
|
|
|
9
|
|
|
class Adminetic |
|
10
|
|
|
{ |
|
11
|
|
|
use SidebarHelper; |
|
12
|
|
|
|
|
13
|
|
|
public function user() |
|
14
|
|
|
{ |
|
15
|
|
|
$user = config('auth.providers.users.model'); |
|
16
|
|
|
|
|
17
|
|
|
return new $user; |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
public function assets(): array |
|
21
|
|
|
{ |
|
22
|
|
|
$client_assets = $this->getClientAssets(); |
|
23
|
|
|
$default_assets = $this->getDefaultAssets(); |
|
24
|
|
|
$getPluginAssets = $this->getPluginAssets(); |
|
25
|
|
|
$allAssets = array_merge($default_assets, $client_assets, $getPluginAssets); |
|
26
|
|
|
|
|
27
|
|
|
$assets = array_unique($allAssets, SORT_REGULAR); |
|
28
|
|
|
|
|
29
|
|
|
return $assets; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function menus(): array |
|
33
|
|
|
{ |
|
34
|
|
|
$client_menus = $this->clientMenus(); |
|
35
|
|
|
$adminetic_menus = $this->admineticMenus(); |
|
36
|
|
|
$plugin_menus = $this->pluginMenus(); |
|
37
|
|
|
$allmenus = array_merge($adminetic_menus, $client_menus, $plugin_menus); |
|
38
|
|
|
|
|
39
|
|
|
return $allmenus; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function getClientAssets(): array |
|
43
|
|
|
{ |
|
44
|
|
|
return config('adminetic.assets', []); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function getDefaultAssets(): array |
|
48
|
|
|
{ |
|
49
|
|
|
return [ |
|
50
|
|
|
[ |
|
51
|
|
|
'name' => 'Datatables', |
|
52
|
|
|
'active' => true, |
|
53
|
|
|
'files' => [ |
|
54
|
|
|
[ |
|
55
|
|
|
'type' => 'css', |
|
56
|
|
|
'active' => true, |
|
57
|
|
|
'location' => 'adminetic/assets/css/vendors/datatables.css', |
|
58
|
|
|
], |
|
59
|
|
|
[ |
|
60
|
|
|
'type' => 'css', |
|
61
|
|
|
'active' => true, |
|
62
|
|
|
'location' => 'adminetic/assets/css/vendors/rowReorder.dataTables.min.css', |
|
63
|
|
|
], |
|
64
|
|
|
[ |
|
65
|
|
|
'type' => 'js', |
|
66
|
|
|
'active' => true, |
|
67
|
|
|
'location' => 'adminetic/assets/js/datatable/datatables/jquery.dataTables.min.js', |
|
68
|
|
|
], |
|
69
|
|
|
[ |
|
70
|
|
|
'type' => 'js', |
|
71
|
|
|
'active' => true, |
|
72
|
|
|
'location' => 'adminetic/assets/js/datatable/datatable-extension/dataTables.buttons.min.js', |
|
73
|
|
|
], |
|
74
|
|
|
[ |
|
75
|
|
|
'type' => 'js', |
|
76
|
|
|
'active' => true, |
|
77
|
|
|
'location' => 'adminetic/assets/js/datatable/datatable-extension/buttons.flash.min.js', |
|
78
|
|
|
], |
|
79
|
|
|
[ |
|
80
|
|
|
'type' => 'js', |
|
81
|
|
|
'active' => true, |
|
82
|
|
|
'location' => 'adminetic/assets/js/datatable/datatable-extension/jszip.min.js', |
|
83
|
|
|
], |
|
84
|
|
|
[ |
|
85
|
|
|
'type' => 'js', |
|
86
|
|
|
'active' => true, |
|
87
|
|
|
'location' => 'adminetic/assets/js/datatable/datatable-extension/pdfmake.min.js', |
|
88
|
|
|
], |
|
89
|
|
|
[ |
|
90
|
|
|
'type' => 'js', |
|
91
|
|
|
'active' => true, |
|
92
|
|
|
'location' => 'adminetic/assets/js/datatable/datatable-extension/vfs_fonts.js', |
|
93
|
|
|
], |
|
94
|
|
|
[ |
|
95
|
|
|
'type' => 'js', |
|
96
|
|
|
'active' => true, |
|
97
|
|
|
'location' => 'adminetic/assets/js/datatable/datatable-extension/buttons.html5.min.js', |
|
98
|
|
|
], |
|
99
|
|
|
[ |
|
100
|
|
|
'type' => 'js', |
|
101
|
|
|
'active' => true, |
|
102
|
|
|
'location' => 'adminetic/assets/js/datatable/datatable-extension/buttons.print.min.js', |
|
103
|
|
|
], |
|
104
|
|
|
[ |
|
105
|
|
|
'type' => 'js', |
|
106
|
|
|
'active' => true, |
|
107
|
|
|
'location' => 'adminetic/assets/js/datatable/datatable-extension/dataTables.rowReorder.min.js', |
|
108
|
|
|
], |
|
109
|
|
|
], |
|
110
|
|
|
], |
|
111
|
|
|
[ |
|
112
|
|
|
'name' => 'Icons', |
|
113
|
|
|
'active' => true, |
|
114
|
|
|
'files' => [ |
|
115
|
|
|
[ |
|
116
|
|
|
'type' => 'css', |
|
117
|
|
|
'active' => true, |
|
118
|
|
|
'location' => 'adminetic/assets/css/fontawesome-all.min.css', |
|
119
|
|
|
], |
|
120
|
|
|
[ |
|
121
|
|
|
'type' => 'css', |
|
122
|
|
|
'active' => true, |
|
123
|
|
|
'location' => 'adminetic/assets/css/vendors/icofont.css', |
|
124
|
|
|
], |
|
125
|
|
|
[ |
|
126
|
|
|
'type' => 'css', |
|
127
|
|
|
'active' => true, |
|
128
|
|
|
'location' => 'adminetic/assets/css/vendors/themify.css', |
|
129
|
|
|
], |
|
130
|
|
|
[ |
|
131
|
|
|
'type' => 'css', |
|
132
|
|
|
'active' => true, |
|
133
|
|
|
'location' => 'adminetic/assets/css/vendors/flag-icon.css', |
|
134
|
|
|
], |
|
135
|
|
|
[ |
|
136
|
|
|
'type' => 'css', |
|
137
|
|
|
'active' => true, |
|
138
|
|
|
'location' => 'adminetic/assets/css/vendors/feather-icon.css', |
|
139
|
|
|
], |
|
140
|
|
|
], |
|
141
|
|
|
], |
|
142
|
|
|
[ |
|
143
|
|
|
'name' => 'Scrollbar', |
|
144
|
|
|
'active' => true, |
|
145
|
|
|
'files' => [ |
|
146
|
|
|
[ |
|
147
|
|
|
'type' => 'css', |
|
148
|
|
|
'active' => true, |
|
149
|
|
|
'location' => 'adminetic/assets/css/vendors/scrollbar.css', |
|
150
|
|
|
], |
|
151
|
|
|
[ |
|
152
|
|
|
'type' => 'js', |
|
153
|
|
|
'active' => true, |
|
154
|
|
|
'location' => 'adminetic/assets/js/scrollbar/simplebar.js', |
|
155
|
|
|
], |
|
156
|
|
|
[ |
|
157
|
|
|
'type' => 'js', |
|
158
|
|
|
'active' => true, |
|
159
|
|
|
'location' => 'adminetic/assets/js/scrollbar/custom.js', |
|
160
|
|
|
], |
|
161
|
|
|
], |
|
162
|
|
|
], |
|
163
|
|
|
[ |
|
164
|
|
|
'name' => 'Touchspin', |
|
165
|
|
|
'active' => true, |
|
166
|
|
|
'files' => [ |
|
167
|
|
|
[ |
|
168
|
|
|
'type' => 'js', |
|
169
|
|
|
'active' => true, |
|
170
|
|
|
'location' => 'adminetic/assets/js/touchspin/touchspin.js', |
|
171
|
|
|
], |
|
172
|
|
|
[ |
|
173
|
|
|
'type' => 'js', |
|
174
|
|
|
'active' => true, |
|
175
|
|
|
'location' => 'adminetic/assets/js/touchspin/input-groups.min.js', |
|
176
|
|
|
], |
|
177
|
|
|
], |
|
178
|
|
|
], |
|
179
|
|
|
[ |
|
180
|
|
|
'name' => 'Animate', |
|
181
|
|
|
'active' => true, |
|
182
|
|
|
'files' => [ |
|
183
|
|
|
[ |
|
184
|
|
|
'type' => 'css', |
|
185
|
|
|
'active' => true, |
|
186
|
|
|
'location' => 'adminetic/assets/css/vendors/animate.css', |
|
187
|
|
|
], |
|
188
|
|
|
], |
|
189
|
|
|
], |
|
190
|
|
|
[ |
|
191
|
|
|
'name' => 'Print This', |
|
192
|
|
|
'active' => true, |
|
193
|
|
|
'files' => [ |
|
194
|
|
|
[ |
|
195
|
|
|
'type' => 'js', |
|
196
|
|
|
'active' => true, |
|
197
|
|
|
'location' => 'adminetic/assets/js/printThis.js', |
|
198
|
|
|
], |
|
199
|
|
|
], |
|
200
|
|
|
], |
|
201
|
|
|
[ |
|
202
|
|
|
'name' => 'Daterange Picker', |
|
203
|
|
|
'active' => true, |
|
204
|
|
|
'files' => [ |
|
205
|
|
|
[ |
|
206
|
|
|
'type' => 'css', |
|
207
|
|
|
'active' => true, |
|
208
|
|
|
'location' => 'adminetic/assets/css/vendors/daterange-picker.css', |
|
209
|
|
|
], |
|
210
|
|
|
[ |
|
211
|
|
|
'type' => 'js', |
|
212
|
|
|
'active' => true, |
|
213
|
|
|
'location' => 'adminetic/assets/js/datepicker/daterange-picker/moment.min.js', |
|
214
|
|
|
], |
|
215
|
|
|
[ |
|
216
|
|
|
'type' => 'js', |
|
217
|
|
|
'active' => true, |
|
218
|
|
|
'location' => 'adminetic/assets/js/datepicker/daterange-picker/daterangepicker.js', |
|
219
|
|
|
], |
|
220
|
|
|
], |
|
221
|
|
|
], |
|
222
|
|
|
[ |
|
223
|
|
|
'name' => 'CKEditor', |
|
224
|
|
|
'active' => true, |
|
225
|
|
|
'files' => [ |
|
226
|
|
|
[ |
|
227
|
|
|
'type' => 'js', |
|
228
|
|
|
'active' => true, |
|
229
|
|
|
'location' => 'adminetic/assets/js/editor/ckeditor/ckeditor.js', |
|
230
|
|
|
], |
|
231
|
|
|
[ |
|
232
|
|
|
'type' => 'js', |
|
233
|
|
|
'active' => true, |
|
234
|
|
|
'location' => 'adminetic/assets/js/editor/ckeditor/styles.js', |
|
235
|
|
|
], |
|
236
|
|
|
], |
|
237
|
|
|
], |
|
238
|
|
|
[ |
|
239
|
|
|
'name' => 'Summernote', |
|
240
|
|
|
'active' => true, |
|
241
|
|
|
'files' => [ |
|
242
|
|
|
[ |
|
243
|
|
|
'type' => 'css', |
|
244
|
|
|
'active' => true, |
|
245
|
|
|
'location' => 'adminetic/assets/css/vendors/summernote.css', |
|
246
|
|
|
], |
|
247
|
|
|
[ |
|
248
|
|
|
'type' => 'js', |
|
249
|
|
|
'active' => true, |
|
250
|
|
|
'location' => 'adminetic/assets/js/editor/summernote/summernote.js', |
|
251
|
|
|
], |
|
252
|
|
|
], |
|
253
|
|
|
], |
|
254
|
|
|
[ |
|
255
|
|
|
'name' => 'Select2', |
|
256
|
|
|
'active' => true, |
|
257
|
|
|
'files' => [ |
|
258
|
|
|
[ |
|
259
|
|
|
'type' => 'css', |
|
260
|
|
|
'active' => true, |
|
261
|
|
|
'location' => 'adminetic/assets/css/vendors/select2.css', |
|
262
|
|
|
], |
|
263
|
|
|
[ |
|
264
|
|
|
'type' => 'js', |
|
265
|
|
|
'active' => true, |
|
266
|
|
|
'location' => 'adminetic/assets/js/select2/select2.full.min.js', |
|
267
|
|
|
], |
|
268
|
|
|
], |
|
269
|
|
|
], |
|
270
|
|
|
[ |
|
271
|
|
|
'name' => 'ACE Editor', |
|
272
|
|
|
'active' => false, |
|
273
|
|
|
'files' => [ |
|
274
|
|
|
[ |
|
275
|
|
|
'type' => 'js', |
|
276
|
|
|
'active' => true, |
|
277
|
|
|
'location' => 'adminetic/assets/js/editor/ace-editor/ace.js', |
|
278
|
|
|
], |
|
279
|
|
|
[ |
|
280
|
|
|
'type' => 'js', |
|
281
|
|
|
'active' => true, |
|
282
|
|
|
'location' => 'adminetic/assets/js/editor/ace-editor/mode-html.js', |
|
283
|
|
|
], |
|
284
|
|
|
], |
|
285
|
|
|
], |
|
286
|
|
|
[ |
|
287
|
|
|
'name' => 'Notify', |
|
288
|
|
|
'active' => true, |
|
289
|
|
|
'files' => [ |
|
290
|
|
|
[ |
|
291
|
|
|
'type' => 'js', |
|
292
|
|
|
'active' => true, |
|
293
|
|
|
'location' => 'adminetic/assets/js/notify/bootstrap-notify.min.js', |
|
294
|
|
|
], |
|
295
|
|
|
], |
|
296
|
|
|
], |
|
297
|
|
|
[ |
|
298
|
|
|
'name' => 'Card', |
|
299
|
|
|
'active' => true, |
|
300
|
|
|
'files' => [ |
|
301
|
|
|
[ |
|
302
|
|
|
'type' => 'js', |
|
303
|
|
|
'active' => true, |
|
304
|
|
|
'location' => 'adminetic/assets/js/custom-card/custom-card.js', |
|
305
|
|
|
], |
|
306
|
|
|
], |
|
307
|
|
|
], |
|
308
|
|
|
]; |
|
309
|
|
|
} |
|
310
|
|
|
|
|
311
|
|
|
public function getPluginAssets(): array |
|
312
|
|
|
{ |
|
313
|
|
|
$pluginAssets = []; |
|
314
|
|
|
if (count($this->getAdapters()) > 0) { |
|
315
|
|
|
foreach ($this->getAdapters() as $adapter) { |
|
316
|
|
|
$pluginAssets = array_merge($pluginAssets, $adapter->assets()); |
|
317
|
|
|
} |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
|
|
return $pluginAssets; |
|
321
|
|
|
} |
|
322
|
|
|
|
|
323
|
|
|
public function admineticMenus(): array |
|
324
|
|
|
{ |
|
325
|
|
|
return []; |
|
326
|
|
|
} |
|
327
|
|
|
|
|
328
|
|
|
public function clientMenus(): array |
|
329
|
|
|
{ |
|
330
|
|
|
$myMenu = config('adminetic.myMenu', \App\Services\MyMenu::class); |
|
|
|
|
|
|
331
|
|
|
if (class_exists($myMenu)) { |
|
332
|
|
|
if (method_exists($myMenu, 'myMenu')) { |
|
333
|
|
|
$menu = new $myMenu; |
|
334
|
|
|
if (is_array($menu->myMenu())) { |
|
335
|
|
|
return $menu->myMenu(); |
|
336
|
|
|
} else { |
|
337
|
|
|
throw new Exception('myMenu method return type must be an array.'); |
|
338
|
|
|
} |
|
339
|
|
|
} else { |
|
340
|
|
|
throw new Exception('myMenu method is not found', 1); |
|
341
|
|
|
} |
|
342
|
|
|
} else { |
|
343
|
|
|
throw new Exception('Given class namespace is not found'); |
|
344
|
|
|
} |
|
345
|
|
|
} |
|
346
|
|
|
|
|
347
|
|
|
public function pluginMenus(): array |
|
348
|
|
|
{ |
|
349
|
|
|
$pluginMenu = []; |
|
350
|
|
|
if (count($this->getAdapters()) > 0) { |
|
351
|
|
|
foreach ($this->getAdapters() as $adapter) { |
|
352
|
|
|
$pluginMenu = array_merge($pluginMenu, $adapter->myMenu()); |
|
353
|
|
|
} |
|
354
|
|
|
} |
|
355
|
|
|
|
|
356
|
|
|
return $pluginMenu; |
|
357
|
|
|
} |
|
358
|
|
|
|
|
359
|
|
|
public function getHeaderData(): array |
|
360
|
|
|
{ |
|
361
|
|
|
$headerData = []; |
|
362
|
|
|
if (count($this->getAdapters()) > 0) { |
|
363
|
|
|
foreach ($this->getAdapters() as $adapter) { |
|
364
|
|
|
if (method_exists($adapter, 'headerData')) { |
|
365
|
|
|
$headerData = array_merge($headerData, $adapter->headerData()); |
|
366
|
|
|
} |
|
367
|
|
|
} |
|
368
|
|
|
} |
|
369
|
|
|
|
|
370
|
|
|
return $headerData; |
|
371
|
|
|
} |
|
372
|
|
|
|
|
373
|
|
|
public function getFooterData(): array |
|
374
|
|
|
{ |
|
375
|
|
|
$footerData = []; |
|
376
|
|
|
if (count($this->getAdapters()) > 0) { |
|
377
|
|
|
foreach ($this->getAdapters() as $adapter) { |
|
378
|
|
|
if (method_exists($adapter, 'footerData')) { |
|
379
|
|
|
$footerData = array_merge($footerData, $adapter->footerData()); |
|
380
|
|
|
} |
|
381
|
|
|
} |
|
382
|
|
|
} |
|
383
|
|
|
|
|
384
|
|
|
return $footerData; |
|
385
|
|
|
} |
|
386
|
|
|
|
|
387
|
|
|
public function getAdapters(): array |
|
388
|
|
|
{ |
|
389
|
|
|
$adapters = []; |
|
390
|
|
|
foreach (config('adminetic.adapters', []) as $adapter) { |
|
391
|
|
|
if (class_exists($adapter)) { |
|
392
|
|
|
$init_adapter = new $adapter; |
|
393
|
|
|
$adapters[] = $init_adapter; |
|
394
|
|
|
} |
|
395
|
|
|
} |
|
396
|
|
|
|
|
397
|
|
|
return $adapters; |
|
398
|
|
|
} |
|
399
|
|
|
|
|
400
|
|
|
private function indexCreateChildren($route, $class) |
|
|
|
|
|
|
401
|
|
|
{ |
|
402
|
|
|
$name = Str::ucfirst($route); |
|
403
|
|
|
$plural = Str::ucfirst(Str::plural($name)); |
|
404
|
|
|
|
|
405
|
|
|
$children = [ |
|
406
|
|
|
[ |
|
407
|
|
|
'type' => 'submenu', |
|
408
|
|
|
'name' => 'All '.$plural, |
|
409
|
|
|
'is_active' => request()->routeIs($route.'.index') ? 'active' : '', |
|
410
|
|
|
'link' => adminRedirectRoute($route), |
|
411
|
|
|
'conditions' => [ |
|
412
|
|
|
[ |
|
413
|
|
|
'type' => 'or', |
|
414
|
|
|
'condition' => auth()->user()->can('view-any', $class), |
|
415
|
|
|
], |
|
416
|
|
|
], |
|
417
|
|
|
], |
|
418
|
|
|
[ |
|
419
|
|
|
'type' => 'submenu', |
|
420
|
|
|
'name' => 'Create '.$route, |
|
421
|
|
|
'is_active' => request()->routeIs($route.'.create') ? 'active' : '', |
|
422
|
|
|
'link' => adminCreateRoute($route), |
|
423
|
|
|
'conditions' => [ |
|
424
|
|
|
[ |
|
425
|
|
|
'type' => 'or', |
|
426
|
|
|
'condition' => auth()->user()->can('create', $class), |
|
427
|
|
|
], |
|
428
|
|
|
], |
|
429
|
|
|
], |
|
430
|
|
|
]; |
|
431
|
|
|
|
|
432
|
|
|
return $children; |
|
433
|
|
|
} |
|
434
|
|
|
} |
|
435
|
|
|
|
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