@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | $sections = Menu::sections()->pluck('name', 'id'); |
48 | 48 | |
49 | - if(! $sections->count()) |
|
49 | + if (!$sections->count()) |
|
50 | 50 | { |
51 | 51 | return redirect() |
52 | 52 | ->route('menu-maker::sections.index') |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $name = $menu->name; |
136 | 136 | |
137 | 137 | $childs = $menu->descendants()->count(); |
138 | - if($childs > 0) |
|
138 | + if ($childs > 0) |
|
139 | 139 | { |
140 | 140 | return redirect() |
141 | 141 | ->back() |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | ->protected() |
160 | 160 | ->toTree($node); |
161 | 161 | $selected = []; |
162 | - if(request()->has('g') && request('g') > 0) |
|
162 | + if (request()->has('g') && request('g') > 0) |
|
163 | 163 | { |
164 | 164 | $selected = Role::findOrFail(request('g'))->menus()->descendantsOf($node)->pluck('id')->toArray(); |
165 | 165 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (! function_exists('is_excluded_route')) { |
|
3 | +if (!function_exists('is_excluded_route')) { |
|
4 | 4 | function is_excluded_route($route) |
5 | 5 | { |
6 | 6 | $namespaces = array_map('valid_namespace', config('menu.exclude.namespaces')); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | -if (! function_exists('is_public_route')) { |
|
29 | +if (!function_exists('is_public_route')) { |
|
30 | 30 | function is_public_route($route) |
31 | 31 | { |
32 | 32 | $route = explode_route($route); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | -if (! function_exists('is_working_route')) { |
|
42 | +if (!function_exists('is_working_route')) { |
|
43 | 43 | function is_working_route($route) |
44 | 44 | { |
45 | 45 | $namespaces = array_map('valid_namespace', config('menu.include.namespaces')); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | -if (! function_exists('explode_route')) { |
|
69 | +if (!function_exists('explode_route')) { |
|
70 | 70 | function explode_route($route) |
71 | 71 | { |
72 | 72 | $actionName = $route->getActionName(); |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | -if (! function_exists('valid_namespace')) { |
|
84 | +if (!function_exists('valid_namespace')) { |
|
85 | 85 | function valid_namespace($namespace) |
86 | 86 | { |
87 | 87 | return str_replace('\\', '\\\\', $namespace); |
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | -if (! function_exists('unauthorized')) { |
|
91 | +if (!function_exists('unauthorized')) { |
|
92 | 92 | function unauthorized() |
93 | 93 | { |
94 | 94 | return response()->view('menu-maker::errors.401'); |
@@ -12,7 +12,7 @@ |
||
12 | 12 | public function rules() |
13 | 13 | { |
14 | 14 | return [ |
15 | - 'name' => 'required|unique:pcmm_roles,name,'.$this->segment($this->segmentNo(), 0), |
|
15 | + 'name' => 'required|unique:pcmm_roles,name,' . $this->segment($this->segmentNo(), 0), |
|
16 | 16 | ]; |
17 | 17 | } |
18 | 18 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -Route::name('menu-maker::')->group(function () { |
|
3 | +Route::name('menu-maker::')->group(function() { |
|
4 | 4 | Route::redirect('/', '/' . config('menu.path') . '/users'); |
5 | 5 | |
6 | 6 | Route::put('roles/assign', 'RoleController@assign')->name('roles.assign'); |
@@ -15,7 +15,7 @@ |
||
15 | 15 | */ |
16 | 16 | public function handle($request, Closure $next) |
17 | 17 | { |
18 | - if (! config('menu.enabled') |
|
18 | + if (!config('menu.enabled') |
|
19 | 19 | || is_excluded_route($request->route()) |
20 | 20 | || is_public_route($request->route()) |
21 | 21 | || optional($request->user())->admin() |
@@ -34,8 +34,8 @@ |
||
34 | 34 | Cache::forget('route-actions'); |
35 | 35 | Cache::forget('public-routes'); |
36 | 36 | $model = resolve('userModel'); |
37 | - $model->chunk(100, function ($users) { |
|
38 | - $users->each(function ($user) { |
|
37 | + $model->chunk(100, function($users) { |
|
38 | + $users->each(function($user) { |
|
39 | 39 | RemoveUserMenuCache::dispatch($user); |
40 | 40 | }); |
41 | 41 | }); |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | private function removeUserCache(Menu $menu) |
56 | 56 | { |
57 | 57 | $menu->load('roles', 'roles.users'); |
58 | - $menu->roles->each(function ($role) { |
|
59 | - $role->users->each(function ($user) { |
|
58 | + $menu->roles->each(function($role) { |
|
59 | + $role->users->each(function($user) { |
|
60 | 60 | RemoveUserMenuCache::dispatch($user); |
61 | 61 | }); |
62 | 62 | }); |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | Cache::forget('public-routes'); |
73 | 73 | |
74 | 74 | $admin = Role::with('users')->admin()->first(); |
75 | - if(! $admin) |
|
75 | + if (!$admin) |
|
76 | 76 | { |
77 | 77 | return; |
78 | 78 | } |
79 | 79 | |
80 | - $admin->users->each(function ($user) { |
|
80 | + $admin->users->each(function($user) { |
|
81 | 81 | RemoveUserMenuCache::dispatch($user); |
82 | 82 | }); |
83 | 83 | } |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | |
61 | 61 | public static function routes() |
62 | 62 | { |
63 | - return Cache::remember('routes', now()->addHour(), function () { |
|
63 | + return Cache::remember('routes', now()->addHour(), function() { |
|
64 | 64 | $filterRoutes = []; |
65 | 65 | $routes = Route::getRoutes(); |
66 | 66 | foreach ($routes as $route) { |
67 | - if (! self::routeMatch($route)) { |
|
67 | + if (!self::routeMatch($route)) { |
|
68 | 68 | continue; |
69 | 69 | } |
70 | 70 | $filterRoutes[] = explode_route($route); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | public static function excludedActionList() |
77 | 77 | { |
78 | - return Cache::rememberForever('excluded-action-list', function () { |
|
78 | + return Cache::rememberForever('excluded-action-list', function() { |
|
79 | 79 | $excluded = collect(); |
80 | 80 | $routes = Route::getRoutes(); |
81 | 81 | foreach ($routes as $route) { |
@@ -89,16 +89,16 @@ discard block |
||
89 | 89 | |
90 | 90 | public static function publicRoutes() |
91 | 91 | { |
92 | - return Cache::rememberForever('public-routes', function () { |
|
92 | + return Cache::rememberForever('public-routes', function() { |
|
93 | 93 | return collect(self::public()->get()->toArray()); |
94 | 94 | }); |
95 | 95 | } |
96 | 96 | |
97 | 97 | public static function actions() |
98 | 98 | { |
99 | - return Cache::rememberForever('route-actions', function () { |
|
99 | + return Cache::rememberForever('route-actions', function() { |
|
100 | 100 | $actions = []; |
101 | - self::routes()->each(function ($route) use (&$actions) { |
|
101 | + self::routes()->each(function($route) use (&$actions) { |
|
102 | 102 | $actions[$route['namespace']][$route['controller']][$route['method']][] = $route['action']; |
103 | 103 | }); |
104 | 104 | ksort($actions); |
@@ -108,12 +108,12 @@ discard block |
||
108 | 108 | |
109 | 109 | private static function routeMatch($route) |
110 | 110 | { |
111 | - return is_working_route($route) && ! is_excluded_route($route); |
|
111 | + return is_working_route($route) && !is_excluded_route($route); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | public function scopeOfRoute(Builder $query, $route) |
115 | 115 | { |
116 | - return $query->where(function ($query) use ($route) { |
|
116 | + return $query->where(function($query) use ($route) { |
|
117 | 117 | $query->where('namespace', $route['namespace']) |
118 | 118 | ->where('controller', $route['controller']) |
119 | 119 | ->where('method', $route['method']) |
@@ -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->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 | return $query->ofRoute($route); |
208 | 208 | })->exists(); |
209 | 209 | } |