@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | public function handle() |
50 | 50 | { |
51 | 51 | $prefix = config('admin.route.prefix'); |
52 | - $routes = collect($this->router->getRoutes())->filter(function (Route $route) use ($prefix) { |
|
52 | + $routes = collect($this->router->getRoutes())->filter(function(Route $route) use ($prefix) { |
|
53 | 53 | $uri = $route->uri(); |
54 | 54 | // built-in, parameterized and no-GET are ignored |
55 | 55 | return Str::startsWith($uri, "{$prefix}/") |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | && in_array('GET', $route->methods()) |
60 | 60 | && !in_array(substr($route->uri(), strlen("{$prefix}/")), config('admin.menu_exclude')); |
61 | 61 | }) |
62 | - ->map(function (Route $route) use ($prefix) { |
|
62 | + ->map(function(Route $route) use ($prefix) { |
|
63 | 63 | $uri = substr($route->uri(), strlen("{$prefix}/")); |
64 | 64 | |
65 | 65 | return [ |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | $menus = Menu::all()->pluck('title', 'uri'); |
75 | 75 | // exclude exist ones |
76 | - $news = $routes->diffKeys($menus)->map(function ($item, $key) { |
|
76 | + $news = $routes->diffKeys($menus)->map(function($item, $key) { |
|
77 | 77 | return [ |
78 | 78 | 'title' => $item, |
79 | 79 | 'uri' => $key, |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | } else { |
88 | 88 | if ($this->hasOption('dry-run') && $this->option('dry-run')) { |
89 | 89 | $this->line('<info>The following menu items will be created</info>: '); |
90 | - $this->table(['Title', 'Uri'], array_map(function ($item) { |
|
90 | + $this->table(['Title', 'Uri'], array_map(function($item) { |
|
91 | 91 | return [ |
92 | 92 | $item['title'], |
93 | 93 | $item['uri'], |
@@ -60,13 +60,13 @@ |
||
60 | 60 | { |
61 | 61 | return [ |
62 | 62 | // Private channel for specific user notifications |
63 | - new PrivateChannel('admin.operations.' . $this->userId), |
|
63 | + new PrivateChannel('admin.operations.'.$this->userId), |
|
64 | 64 | |
65 | 65 | // General admin channel for all admin users |
66 | 66 | new PrivateChannel('admin.notifications'), |
67 | 67 | |
68 | 68 | // Model-specific channel for grid updates |
69 | - new PrivateChannel('admin.grid.' . strtolower(class_basename($this->model))), |
|
69 | + new PrivateChannel('admin.grid.'.strtolower(class_basename($this->model))), |
|
70 | 70 | ]; |
71 | 71 | } |
72 | 72 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | return $callback(); |
44 | 44 | } |
45 | 45 | |
46 | - $cacheKey = $config['prefix'] . ':' . $key; |
|
46 | + $cacheKey = $config['prefix'].':'.$key; |
|
47 | 47 | $ttl = $ttl ?? $config['ttl']; |
48 | 48 | |
49 | 49 | return Cache::driver($config['driver'])->remember($cacheKey, $ttl, $callback); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | return $this->buildMenu(); |
61 | 61 | } |
62 | 62 | |
63 | - return $this->getCached('menu:' . auth('admin')->id(), function () { |
|
63 | + return $this->getCached('menu:'.auth('admin')->id(), function() { |
|
64 | 64 | return $this->buildMenu(); |
65 | 65 | }, 1800); // 30 minutes |
66 | 66 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | return $this->buildPermissions($userId); |
78 | 78 | } |
79 | 79 | |
80 | - return $this->getCached("permissions:{$userId}", function () use ($userId) { |
|
80 | + return $this->getCached("permissions:{$userId}", function() use ($userId) { |
|
81 | 81 | return $this->buildPermissions($userId); |
82 | 82 | }, 3600); // 1 hour |
83 | 83 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | return $this->buildRoles($userId); |
95 | 95 | } |
96 | 96 | |
97 | - return $this->getCached("roles:{$userId}", function () use ($userId) { |
|
97 | + return $this->getCached("roles:{$userId}", function() use ($userId) { |
|
98 | 98 | return $this->buildRoles($userId); |
99 | 99 | }, 3600); // 1 hour |
100 | 100 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param string|array $keys |
106 | 106 | * @return void |
107 | 107 | */ |
108 | - protected function clearCache(string|array $keys): void |
|
108 | + protected function clearCache(string | array $keys): void |
|
109 | 109 | { |
110 | 110 | $config = $this->getCacheConfig(); |
111 | 111 | $cache = Cache::driver($config['driver']); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $keys = is_array($keys) ? $keys : [$keys]; |
114 | 114 | |
115 | 115 | foreach ($keys as $key) { |
116 | - $cacheKey = $config['prefix'] . ':' . $key; |
|
116 | + $cacheKey = $config['prefix'].':'.$key; |
|
117 | 117 | $cache->forget($cacheKey); |
118 | 118 | } |
119 | 119 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $cache = Cache::driver($config['driver']); |
130 | 130 | |
131 | 131 | // Clear all keys with admin prefix |
132 | - $pattern = $config['prefix'] . ':*'; |
|
132 | + $pattern = $config['prefix'].':*'; |
|
133 | 133 | |
134 | 134 | // For Redis driver |
135 | 135 | if ($config['driver'] === 'redis') { |
@@ -23,7 +23,7 @@ |
||
23 | 23 | public static function useVite(): bool |
24 | 24 | { |
25 | 25 | return config('admin.assets.use_vite', false) && |
26 | - file_exists(public_path(config('admin.assets.vite_build_path', 'build') . '/manifest.json')); |
|
26 | + file_exists(public_path(config('admin.assets.vite_build_path', 'build').'/manifest.json')); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | $method = $this->http_method; |
85 | 85 | |
86 | - $matches = array_map(function ($path) use ($method) { |
|
86 | + $matches = array_map(function($path) use ($method) { |
|
87 | 87 | $path = trim(config('admin.route.prefix'), '/').$path; |
88 | 88 | |
89 | 89 | if (Str::contains($path, ':')) { |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | return false; |
137 | 137 | } |
138 | 138 | |
139 | - $method = collect($match['method'])->filter()->map(function ($method) { |
|
139 | + $method = collect($match['method'])->filter()->map(function($method) { |
|
140 | 140 | return strtoupper($method); |
141 | 141 | }); |
142 | 142 | |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | protected function httpMethod(): Attribute |
153 | 153 | { |
154 | 154 | return Attribute::make( |
155 | - get: function ($value) { |
|
155 | + get: function($value) { |
|
156 | 156 | if (is_string($value)) { |
157 | 157 | return array_filter(explode(',', $value)); |
158 | 158 | } |
159 | 159 | return $value ?: []; |
160 | 160 | }, |
161 | - set: function ($value) { |
|
161 | + set: function($value) { |
|
162 | 162 | if (is_array($value)) { |
163 | 163 | return implode(',', array_filter($value)); |
164 | 164 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | { |
213 | 213 | parent::boot(); |
214 | 214 | |
215 | - static::deleting(function ($model) { |
|
215 | + static::deleting(function($model) { |
|
216 | 216 | $model->roles()->detach(); |
217 | 217 | }); |
218 | 218 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | protected function fullUrl(): Attribute |
102 | 102 | { |
103 | 103 | return Attribute::make( |
104 | - get: function () { |
|
104 | + get: function() { |
|
105 | 105 | if (empty($this->uri)) { |
106 | 106 | return '#'; |
107 | 107 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | protected function isActive(): Attribute |
124 | 124 | { |
125 | 125 | return Attribute::make( |
126 | - get: fn() => request()->is(trim($this->uri, '/') . '*') |
|
126 | + get: fn() => request()->is(trim($this->uri, '/').'*') |
|
127 | 127 | ); |
128 | 128 | } |
129 | 129 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | protected function depth(): Attribute |
148 | 148 | { |
149 | 149 | return Attribute::make( |
150 | - get: function () { |
|
150 | + get: function() { |
|
151 | 151 | $depth = 0; |
152 | 152 | $parent = $this->parent; |
153 | 153 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | { |
181 | 181 | static::treeBoot(); |
182 | 182 | |
183 | - static::deleting(function ($model) { |
|
183 | + static::deleting(function($model) { |
|
184 | 184 | $model->roles()->detach(); |
185 | 185 | }); |
186 | 186 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | protected function avatar(): Attribute |
61 | 61 | { |
62 | 62 | return Attribute::make( |
63 | - get: function ($value) { |
|
63 | + get: function($value) { |
|
64 | 64 | if ($value && url()->isValidUrl($value)) { |
65 | 65 | return $value; |
66 | 66 | } |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | protected function displayPath(): Attribute |
77 | 77 | { |
78 | 78 | return Attribute::make( |
79 | - get: function () { |
|
79 | + get: function() { |
|
80 | 80 | $adminPrefix = config('admin.route.prefix', 'admin'); |
81 | - return str_replace($adminPrefix . '/', '', $this->path); |
|
81 | + return str_replace($adminPrefix.'/', '', $this->path); |
|
82 | 82 | } |
83 | 83 | ); |
84 | 84 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | protected function wasSuccessful(): Attribute |
104 | 104 | { |
105 | 105 | return Attribute::make( |
106 | - get: function () { |
|
106 | + get: function() { |
|
107 | 107 | // Check for error indicators in input data |
108 | 108 | if (!$this->input) return true; |
109 | 109 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | protected function sanitizedInput(): Attribute |
122 | 122 | { |
123 | 123 | return Attribute::make( |
124 | - get: function () { |
|
124 | + get: function() { |
|
125 | 125 | if (!$this->input) return []; |
126 | 126 | |
127 | 127 | $input = is_array($this->input) ? $this->input : $this->input->toArray(); |
@@ -105,7 +105,9 @@ discard block |
||
105 | 105 | return Attribute::make( |
106 | 106 | get: function () { |
107 | 107 | // Check for error indicators in input data |
108 | - if (!$this->input) return true; |
|
108 | + if (!$this->input) { |
|
109 | + return true; |
|
110 | + } |
|
109 | 111 | |
110 | 112 | $input = is_array($this->input) ? $this->input : $this->input->toArray(); |
111 | 113 | return !isset($input['error']) && !isset($input['exception']); |
@@ -122,7 +124,9 @@ discard block |
||
122 | 124 | { |
123 | 125 | return Attribute::make( |
124 | 126 | get: function () { |
125 | - if (!$this->input) return []; |
|
127 | + if (!$this->input) { |
|
128 | + return []; |
|
129 | + } |
|
126 | 130 | |
127 | 131 | $input = is_array($this->input) ? $this->input : $this->input->toArray(); |
128 | 132 |
@@ -322,10 +322,10 @@ discard block |
||
322 | 322 | 'middleware' => config('admin.route.middleware'), |
323 | 323 | ]; |
324 | 324 | |
325 | - app('router')->group($attributes, function ($router) { |
|
325 | + app('router')->group($attributes, function($router) { |
|
326 | 326 | |
327 | 327 | /* @var \Illuminate\Support\Facades\Route $router */ |
328 | - $router->namespace('\Encore\Admin\Controllers')->group(function ($router) { |
|
328 | + $router->namespace('\Encore\Admin\Controllers')->group(function($router) { |
|
329 | 329 | |
330 | 330 | /* @var \Illuminate\Routing\Router $router */ |
331 | 331 | $router->resource('auth/users', 'UserController')->names('admin.auth.users'); |
@@ -371,9 +371,9 @@ discard block |
||
371 | 371 | 'middleware' => config('admin.route.api.middleware', ['api']), |
372 | 372 | ]; |
373 | 373 | |
374 | - app('router')->group($attributes, function ($router) { |
|
374 | + app('router')->group($attributes, function($router) { |
|
375 | 375 | /* @var \Illuminate\Support\Facades\Route $router */ |
376 | - $router->namespace('\Encore\Admin\Controllers')->group(function ($router) { |
|
376 | + $router->namespace('\Encore\Admin\Controllers')->group(function($router) { |
|
377 | 377 | /* @var \Illuminate\Routing\Router $router */ |
378 | 378 | |
379 | 379 | // API endpoints for admin resources |