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