Completed
Pull Request — master (#5883)
by
unknown
28s
created
src/Actions/RowSimpleAction.php 1 patch
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -61,8 +61,9 @@  discard block
 block discarded – undo
61 61
     private function renderDefault(): void
62 62
     {
63 63
         $render_key = get_called_class().'-default';
64
-        if (array_key_exists($render_key, static::$is_rendered))
65
-            return;
64
+        if (array_key_exists($render_key, static::$is_rendered)) {
65
+                    return;
66
+        }
66 67
         static::$is_rendered[$render_key] = true;
67 68
 
68 69
         $parameters = json_encode($this->parameters());
@@ -106,8 +107,9 @@  discard block
 block discarded – undo
106 107
         }
107 108
 
108 109
         $render_key = get_called_class().'-dialog';
109
-        if (array_key_exists($render_key, static::$is_rendered))
110
-            return;
110
+        if (array_key_exists($render_key, static::$is_rendered)) {
111
+                    return;
112
+        }
111 113
         static::$is_rendered[$render_key] = true;
112 114
 
113 115
         $parameters = json_encode($this->parameters());
@@ -178,8 +180,9 @@  discard block
 block discarded – undo
178 180
                 'label' => $row['label'],
179 181
             ];
180 182
 
181
-            if (!empty($row['rules']) && in_array('required', $row['rules']))
182
-                $tmp['is_required'] = 1;
183
+            if (!empty($row['rules']) && in_array('required', $row['rules'])) {
184
+                            $tmp['is_required'] = 1;
185
+            }
183 186
 
184 187
             if (array_key_exists('options', $row)) {
185 188
                 if (empty(static::$select_options)) {
@@ -201,8 +204,9 @@  discard block
 block discarded – undo
201 204
             $props[] = $tmp;
202 205
         }
203 206
 
204
-        if (!empty($props))
205
-            $this->attribute('data-props', json_encode($props, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
207
+        if (!empty($props)) {
208
+                    $this->attribute('data-props', json_encode($props, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
209
+        }
206 210
 
207 211
         $confirm = (new \ReflectionClass($this->interactor))->getProperty('confirm')->getValue($this->interactor);
208 212
         if (!empty($confirm)) {
@@ -210,8 +214,9 @@  discard block
 block discarded – undo
210 214
         }
211 215
 
212 216
         $render_key = get_called_class().'-form';
213
-        if (array_key_exists($render_key, static::$is_rendered))
214
-            return;
217
+        if (array_key_exists($render_key, static::$is_rendered)) {
218
+                    return;
219
+        }
215 220
         static::$is_rendered[$render_key] = true;
216 221
 
217 222
         $this->interactor->addModalHtml();
Please login to merge, or discard this patch.
src/Grid/Displayers/Copyable.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,8 +31,9 @@
 block discarded – undo
31 31
     public function display(): string
32 32
     {
33 33
         $content = $this->getColumn()->getOriginal();
34
-        if (is_null($content) || $content === '')
35
-            return '';
34
+        if (is_null($content) || $content === '') {
35
+                    return '';
36
+        }
36 37
 
37 38
         $this->addScript();
38 39
 
Please login to merge, or discard this patch.
src/Grid/Filter/Period.php 1 patch
Braces   +21 added lines, -14 removed lines patch added patch discarded remove patch
@@ -122,12 +122,14 @@  discard block
 block discarded – undo
122 122
         if (!empty($periods)) {
123 123
             $res = [];
124 124
             foreach ($periods as $period) {
125
-                if (array_key_exists($period, self::PERIODS))
126
-                    $res[] = $period;
125
+                if (array_key_exists($period, self::PERIODS)) {
126
+                                    $res[] = $period;
127
+                }
127 128
             }
128 129
 
129
-            if (!empty($res))
130
-                $this->periods = $res;
130
+            if (!empty($res)) {
131
+                            $this->periods = $res;
132
+            }
131 133
         }
132 134
 
133 135
         return $this;
@@ -140,8 +142,9 @@  discard block
 block discarded – undo
140 142
     public function condition($inputs)
141 143
     {
142 144
         $type = $inputs[$this->column]['type'] ?? $this->getDefault();
143
-        if ($this->ignore || !$type || !array_key_exists($type, self::PERIODS))
144
-            return;
145
+        if ($this->ignore || !$type || !array_key_exists($type, self::PERIODS)) {
146
+                    return;
147
+        }
145 148
 
146 149
         if ($type === self::CUSTOM_DATE || $type === self::CUSTOM_DATETIME) {
147 150
             return $this->handleCustomDate($inputs, $type);
@@ -180,20 +183,23 @@  discard block
 block discarded – undo
180 183
     protected function handleCustomDate(array $inputs, string $type): mixed
181 184
     {
182 185
         $value = $inputs[$this->column][$type] ?? null;
183
-        if (!$value)
184
-            return null;
186
+        if (!$value) {
187
+                    return null;
188
+        }
185 189
 
186 190
         $format = self::CUSTOM_FORMATS[$type];
187 191
         foreach ($value as $key => $row) {
188 192
             $date = \DateTime::createFromFormat($format, $row);
189
-            if (!$date)
190
-                return null;
193
+            if (!$date) {
194
+                            return null;
195
+            }
191 196
 
192 197
             $value[$key] = $date->format($format);
193 198
         }
194 199
 
195
-        if ($type === self::CUSTOM_DATE && !empty($value['end']))
196
-            $value['end'] .= ' 23:59:59';
200
+        if ($type === self::CUSTOM_DATE && !empty($value['end'])) {
201
+                    $value['end'] .= ' 23:59:59';
202
+        }
197 203
 
198 204
         return match (true) {
199 205
             !isset($value['start']) => $this->buildCondition($this->column, '<=', $value['end']),
@@ -286,8 +292,9 @@  discard block
 block discarded – undo
286 292
     public static function isNotFilled(string $column): bool
287 293
     {
288 294
         $request = request()->query($column);
289
-        if (!$request)
290
-            return true;
295
+        if (!$request) {
296
+                    return true;
297
+        }
291 298
 
292 299
         $type = $request['type'] ?? null;
293 300
 
Please login to merge, or discard this patch.
src/Grid/Column.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -438,8 +438,9 @@
 block discarded – undo
438 438
     {
439 439
         return $this->display(function ($val) {
440 440
             $json = json_decode($val, true);
441
-            if (!$json || !is_array($json))
442
-                return e($val);
441
+            if (!$json || !is_array($json)) {
442
+                            return e($val);
443
+            }
443 444
             return '<pre>'.e(json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)).'</pre>';
444 445
         })->style(implode(';', [
445 446
             'max-width: '.$max_width.'px',
Please login to merge, or discard this patch.
src/Show/Field.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -245,8 +245,9 @@
 block discarded – undo
245 245
     {
246 246
         return function ($val) {
247 247
             $json = json_decode($val, true);
248
-            if (!$json || !is_array($json))
249
-                return e($val);
248
+            if (!$json || !is_array($json)) {
249
+                            return e($val);
250
+            }
250 251
             $res = '<pre>';
251 252
             foreach ($json as $lang => $text) {
252 253
                 if (is_string($text) || is_numeric($text)) {
Please login to merge, or discard this patch.
src/Auth/Database/HasPermissions.php 1 patch
Braces   +30 added lines, -20 removed lines patch added patch discarded remove patch
@@ -10,15 +10,17 @@  discard block
 block discarded – undo
10 10
     private function getRolePermissions(): array
11 11
     {
12 12
         static $role_permissions = [];
13
-        if (!empty($role_permissions))
14
-            return $role_permissions;
13
+        if (!empty($role_permissions)) {
14
+                    return $role_permissions;
15
+        }
15 16
 
16 17
         $cache = config('admin.cache')['enable'] ? Cache::store(config('admin.cache')['store']) : null;
17 18
         $cache_key = 'admin_role_permissions';
18 19
         if ($cache) {
19 20
             $role_permissions = $cache->get($cache_key) ?? [];
20
-            if (!empty($role_permissions))
21
-                return $role_permissions;
21
+            if (!empty($role_permissions)) {
22
+                            return $role_permissions;
23
+            }
22 24
         }
23 25
 
24 26
         $roles = Role::with('permissions')->get();
@@ -26,8 +28,9 @@  discard block
 block discarded – undo
26 28
             $role_permissions[$role->id] = $role->permissions->toArray();
27 29
         }
28 30
 
29
-        if ($cache)
30
-            $cache->put($cache_key, $role_permissions, 600);
31
+        if ($cache) {
32
+                    $cache->put($cache_key, $role_permissions, 600);
33
+        }
31 34
 
32 35
         return $role_permissions;
33 36
     }
@@ -35,15 +38,17 @@  discard block
 block discarded – undo
35 38
     private function getUserPermissions(): array
36 39
     {
37 40
         static $user_permissions = [];
38
-        if (!empty($user_permissions[$this->id]))
39
-            return $user_permissions[$this->id];
41
+        if (!empty($user_permissions[$this->id])) {
42
+                    return $user_permissions[$this->id];
43
+        }
40 44
 
41 45
         $cache = config('admin.cache')['enable'] ? Cache::store(config('admin.cache')['store']) : null;
42 46
         $cache_key = 'admin_user_permissions';
43 47
         if ($cache) {
44 48
             $user_permissions = $cache->get($cache_key) ?? [];
45
-            if (!empty($user_permissions[$this->id]))
46
-                return $user_permissions[$this->id];
49
+            if (!empty($user_permissions[$this->id])) {
50
+                            return $user_permissions[$this->id];
51
+            }
47 52
         }
48 53
 
49 54
         $user_permissions[$this->id] = [
@@ -51,8 +56,9 @@  discard block
 block discarded – undo
51 56
             'permissions' => $this->permissions->toArray(),
52 57
         ];
53 58
 
54
-        if ($cache)
55
-            $cache->put($cache_key, $user_permissions, 600);
59
+        if ($cache) {
60
+                    $cache->put($cache_key, $user_permissions, 600);
61
+        }
56 62
 
57 63
         return $user_permissions[$this->id];
58 64
     }
@@ -111,16 +117,18 @@  discard block
 block discarded – undo
111 117
                 'user_permissions' => array_column($this->getUserPermissions()['permissions'], 'slug'),
112 118
             ];
113 119
         }
114
-        if (in_array($ability, $can[$this->id]['user_permissions']))
115
-            return true;
120
+        if (in_array($ability, $can[$this->id]['user_permissions'])) {
121
+                    return true;
122
+        }
116 123
 
117 124
         if (!isset($can[$this->id]['role_permissions'])) {
118 125
             $permissions = [];
119 126
             $role_ids = array_column($this->getUserPermissions()['roles'], 'id');
120 127
             $role_permissions = $this->getRolePermissions();
121 128
             foreach ($role_ids as $role_id) {
122
-                if (!empty($role_permissions[$role_id]))
123
-                    $permissions = array_merge($permissions, $role_permissions[$role_id]);
129
+                if (!empty($role_permissions[$role_id])) {
130
+                                    $permissions = array_merge($permissions, $role_permissions[$role_id]);
131
+                }
124 132
             }
125 133
             $can[$this->id]['role_permissions'] = array_column($permissions, 'slug');
126 134
         }
@@ -148,8 +156,9 @@  discard block
 block discarded – undo
148 156
     public function isAdministrator(): bool
149 157
     {
150 158
         static $is_administrator = [];
151
-        if (!isset($is_administrator[$this->id]))
152
-            $is_administrator[$this->id] = $this->isRole('administrator');
159
+        if (!isset($is_administrator[$this->id])) {
160
+                    $is_administrator[$this->id] = $this->isRole('administrator');
161
+        }
153 162
 
154 163
         return $is_administrator[$this->id];
155 164
     }
@@ -181,8 +190,9 @@  discard block
 block discarded – undo
181 190
     private function getUserRoles(): array
182 191
     {
183 192
         static $user_roles = [];
184
-        if (!isset($user_roles[$this->id]))
185
-            $user_roles[$this->id] = array_column($this->getUserPermissions()['roles'], 'slug');
193
+        if (!isset($user_roles[$this->id])) {
194
+                    $user_roles[$this->id] = array_column($this->getUserPermissions()['roles'], 'slug');
195
+        }
186 196
 
187 197
         return $user_roles[$this->id];
188 198
     }
Please login to merge, or discard this patch.
src/Facades/Admin.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,8 +43,9 @@
 block discarded – undo
43 43
     public static function clearCache(): void
44 44
     {
45 45
         $cache = config('admin.cache')['enable'] ? Cache::store(config('admin.cache')['store']) : null;
46
-        if (!$cache)
47
-            return;
46
+        if (!$cache) {
47
+                    return;
48
+        }
48 49
 
49 50
         $cache->delete('admin_menu');
50 51
         $cache->delete('admin_role_permissions');
Please login to merge, or discard this patch.
src/Listeners/AuthListener.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,8 +42,9 @@
 block discarded – undo
42 42
     {
43 43
         $user->remember_token = null;
44 44
         $user->google2fa_remember_token = null;
45
-        if ($change_password)
46
-            $user->password = Hash::make(Str::random(32));
45
+        if ($change_password) {
46
+                    $user->password = Hash::make(Str::random(32));
47
+        }
47 48
         $user->save();
48 49
 
49 50
         Admin::guard()->logout();
Please login to merge, or discard this patch.