Conditions | 9 |
Paths | 8 |
Total Lines | 38 |
Code Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 90 |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
34 | protected function getAdminMenu($list) |
||
35 | { |
||
36 | $menus = collect(); |
||
37 | foreach ($list as $key => $items) { |
||
38 | if (is_string($items)) { |
||
39 | $name = 'admin.' . $items; |
||
40 | if (Route::has($name)) { |
||
41 | if (Auth::user()->can($name)) { |
||
42 | $menus->push([ |
||
43 | 'title' => $key, |
||
44 | 'url' => route($name), |
||
45 | 'child' => [], |
||
46 | ]); |
||
47 | } |
||
48 | } else { |
||
49 | $config = $this->configFactory->make($items); |
||
50 | if ($config && $config->getAttribute('permissions.view')) { |
||
51 | $menus->push([ |
||
52 | 'title' => $config->getAttribute('title'), |
||
53 | 'url' => ('/' . str_replace('.', '/', $name)), |
||
54 | 'child' => [], |
||
55 | ]); |
||
56 | } |
||
57 | } |
||
58 | } elseif (is_array($items)) { // child |
||
59 | $childs = $this->getAdminMenu($items); |
||
60 | if ($childs->isNotEmpty()) { |
||
61 | $menu = [ |
||
62 | 'title' => $key, |
||
63 | 'url' => '/#', |
||
64 | 'child' => $childs, |
||
65 | ]; |
||
66 | $menus->push($menu); |
||
67 | } |
||
68 | } |
||
69 | } |
||
70 | return $menus; |
||
71 | } |
||
72 | } |
||
73 |