| @@ -4,7 +4,7 @@ discard block | ||
| 4 | 4 | use Faker\Generator as Faker; | 
| 5 | 5 | use PhpCollective\MenuMaker\Storage\Menu; | 
| 6 | 6 | |
| 7 | -$factory->define(Menu::class, function (Faker $faker) { | |
| 7 | +$factory->define(Menu::class, function(Faker $faker) { | |
| 8 | 8 | return [ | 
| 9 | 9 | 'name' => $faker->word, | 
| 10 | 10 | 'alias' => $faker->unique()->slug, | 
| @@ -15,7 +15,7 @@ discard block | ||
| 15 | 15 | ]; | 
| 16 | 16 | }); | 
| 17 | 17 | |
| 18 | -$factory->state(Menu::class, 'section', function ($faker) { | |
| 18 | +$factory->state(Menu::class, 'section', function($faker) { | |
| 19 | 19 | return [ | 
| 20 | 20 | 'name' => $faker->word, | 
| 21 | 21 | 'alias' => $faker->unique()->slug, | 
| @@ -24,7 +24,7 @@ discard block | ||
| 24 | 24 |      { | 
| 25 | 25 | $this->section = Menu::whereAlias($alias)->first(); | 
| 26 | 26 | |
| 27 | -        if (! $this->section) { | |
| 27 | +        if (!$this->section) { | |
| 28 | 28 | return collect([]); | 
| 29 | 29 | } | 
| 30 | 30 | return $this->getMenuItemsWithActive(); | 
| @@ -37,11 +37,11 @@ discard block | ||
| 37 | 37 | $currentPath = request()->path(); | 
| 38 | 38 | $menus = $this->getMenuItems(); | 
| 39 | 39 | |
| 40 | -        $traverse = function ($menus) use (&$traverse, $currentRoute, $currentPath) { | |
| 40 | +        $traverse = function($menus) use (&$traverse, $currentRoute, $currentPath) { | |
| 41 | 41 | $checked = collect([]); | 
| 42 | 42 |              foreach ($menus as $key => $menu) { | 
| 43 | 43 | $menu['children'] = $traverse($menu['children'], $currentRoute, $currentPath); | 
| 44 | - if((is_array($menu['routes']) && in_array($currentRoute, $menu['routes'])) | |
| 44 | + if ((is_array($menu['routes']) && in_array($currentRoute, $menu['routes'])) | |
| 45 | 45 | || $currentPath === $menu['link'] | 
| 46 | 46 |                      || $menu['children']->where('active', true)->count()) | 
| 47 | 47 |                  { | 
| @@ -58,7 +58,7 @@ discard block | ||
| 58 | 58 | |
| 59 | 59 | protected function getMenuItems() | 
| 60 | 60 |      { | 
| 61 | -        return Cache::rememberForever('menus.section.' . optional($this->section)->id . '.user.' . $this->id, function () { | |
| 61 | +        return Cache::rememberForever('menus.section.' . optional($this->section)->id . '.user.' . $this->id, function() { | |
| 62 | 62 | return $this->admin() | 
| 63 | 63 | ? $this->getAdminMenuItems() | 
| 64 | 64 | : $this->getUserMenuItems(); | 
| @@ -68,7 +68,7 @@ discard block | ||
| 68 | 68 | private function getAdminMenuItems() | 
| 69 | 69 |      { | 
| 70 | 70 | $this->section->load([ | 
| 71 | -            'descendants' => function ($query) { | |
| 71 | +            'descendants' => function($query) { | |
| 72 | 72 | $query->visible(); | 
| 73 | 73 | } | 
| 74 | 74 | ]); | 
| @@ -79,9 +79,9 @@ discard block | ||
| 79 | 79 | private function getUserMenuItems() | 
| 80 | 80 |      { | 
| 81 | 81 | $this->section->load([ | 
| 82 | -            'descendants' => function ($query) { | |
| 82 | +            'descendants' => function($query) { | |
| 83 | 83 | $query->with([ | 
| 84 | -                    'ancestors' => function ($query) { | |
| 84 | +                    'ancestors' => function($query) { | |
| 85 | 85 | $query->descendantsOf($this->section); | 
| 86 | 86 | } | 
| 87 | 87 |                  ])->select('pcmm_menus.*') | 
| @@ -90,9 +90,9 @@ discard block | ||
| 90 | 90 |                      ->leftJoin('pcmm_role_user', 'pcmm_roles.id', '=', 'pcmm_role_user.role_id') | 
| 91 | 91 | ->leftJoin($this->getTable(), 'pcmm_role_user.user_id', '=', $this->getTable() . '.id') | 
| 92 | 92 | ->visible() | 
| 93 | -                    ->where(function ($query) { | |
| 93 | +                    ->where(function($query) { | |
| 94 | 94 |                          $query->wherePrivilege('PUBLIC') | 
| 95 | -                            ->orWhere(function ($query) { | |
| 95 | +                            ->orWhere(function($query) { | |
| 96 | 96 |                                  $query->where('pcmm_menus.privilege', 'PROTECTED') | 
| 97 | 97 |                                      ->where('pcmm_roles.is_active', true) | 
| 98 | 98 | ->where($this->getTable() . '.id', $this->id); | 
| @@ -101,7 +101,7 @@ discard block | ||
| 101 | 101 | } | 
| 102 | 102 | ]); | 
| 103 | 103 | |
| 104 | -        $items = $this->section->descendants->reject(function ($item) { | |
| 104 | +        $items = $this->section->descendants->reject(function($item) { | |
| 105 | 105 |              return $item->ancestors->contains('privilege', 'PRIVATE') | 
| 106 | 106 |                  || $item->ancestors->contains('visible', false); | 
| 107 | 107 | }); | 
| @@ -195,7 +195,7 @@ discard block | ||
| 195 | 195 | |
| 196 | 196 | public function approve($alias) | 
| 197 | 197 |      { | 
| 198 | -        return $this->admin() || $this->whereHas('roles.menus', function ($query) use ($alias) { | |
| 198 | +        return $this->admin() || $this->whereHas('roles.menus', function($query) use ($alias) { | |
| 199 | 199 | $query->whereAlias($alias); | 
| 200 | 200 | })->exists(); | 
| 201 | 201 | } | 
| @@ -203,7 +203,7 @@ discard block | ||
| 203 | 203 | public function authorize($request) | 
| 204 | 204 |      { | 
| 205 | 205 | $route = explode_route($request->route()); | 
| 206 | -        return $this->whereHas('roles.menus.permissions', function ($query) use ($route) { | |
| 206 | +        return $this->whereHas('roles.menus.permissions', function($query) use ($route) { | |
| 207 | 207 |              $query->where('namespace', $route['namespace']) | 
| 208 | 208 |                  ->where('controller', $route['controller']) | 
| 209 | 209 |                  ->where('method', $route['method']) |