Passed
Pull Request — master (#1574)
by
unknown
06:27 queued 02:54
created
src/controllers/SubModuleController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@  discard block
 block discarded – undo
14 14
 {
15 15
 
16 16
     public function getSubModule($subModuleKey) {
17
-        if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
18
-        if(!verifyReferalUrl()) return cb()->redirect(module()->url(),"It looks like your url is incorrect");
17
+        if (!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area"));
18
+        if (!verifyReferalUrl()) return cb()->redirect(module()->url(), "It looks like your url is incorrect");
19 19
 
20
-        if($subModule = Cache::get("subModule".$subModuleKey)) {
20
+        if ($subModule = Cache::get("subModule".$subModuleKey)) {
21 21
             $foreignKey = $subModule['foreignKey'];
22 22
             $foreignValue = $subModule['foreignValue'];
23 23
 
24 24
             $query = $this->repository();
25 25
             $query->where($foreignKey, $foreignValue);
26
-            $result = $query->paginate( request("limit")?:$this->data["limit"] );
26
+            $result = $query->paginate(request("limit") ?: $this->data["limit"]);
27 27
             $data['result'] = $result;
28 28
 
29 29
             $data['additionalHeaderTitle'] = $subModule['parentTitle'];
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
             return view("crudbooster::module.index.index", array_merge($data, $this->data));
34 34
         }
35 35
 
36
-        return cb()->redirect(module()->url(),"It looks like your url is incorrect");
36
+        return cb()->redirect(module()->url(), "It looks like your url is incorrect");
37 37
     }
38 38
 
39 39
 }
40 40
\ No newline at end of file
Please login to merge, or discard this patch.
src/helpers/Helper.php 1 patch
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -3,64 +3,64 @@  discard block
 block discarded – undo
3 3
 /*
4 4
  * Theme Helper
5 5
  */
6
-if(!function_exists("themeLoginBackground")) {
6
+if (!function_exists("themeLoginBackground")) {
7 7
     function themeLoginBackground() {
8 8
         return "crudbooster::layouts.login_background_css";
9 9
     }
10 10
 }
11
-if(!function_exists("themeFlashMessageAlert")) {
11
+if (!function_exists("themeFlashMessageAlert")) {
12 12
     function themeFlashMessageAlert() {
13 13
         return "crudbooster::layouts.flash_message_alert";
14 14
     }
15 15
 }
16 16
 
17
-if(!function_exists("themeFlashMessage")) {
17
+if (!function_exists("themeFlashMessage")) {
18 18
     function themeFlashMessage() {
19 19
         return "crudbooster::layouts.flash_message";
20 20
     }
21 21
 }
22 22
 
23
-if(!function_exists("themeAlertMessage")) {
23
+if (!function_exists("themeAlertMessage")) {
24 24
     function themeAlertMessage() {
25 25
         return "crudbooster::layouts.alert_message";
26 26
     }
27 27
 }
28 28
 
29
-if(!function_exists("themeLayoutPageTitleAndButton")) {
29
+if (!function_exists("themeLayoutPageTitleAndButton")) {
30 30
     function themeLayoutPageTitleAndButton() {
31 31
         return 'crudbooster::module.index.index_head_buttons';
32 32
     }
33 33
 }
34 34
 
35
-if(!function_exists("themeLayoutHead")) {
35
+if (!function_exists("themeLayoutHead")) {
36 36
     function themeLayoutHead() {
37 37
         return "crudbooster::layouts.head";
38 38
     }
39 39
 }
40
-if(!function_exists("themeTitle")) {
40
+if (!function_exists("themeTitle")) {
41 41
     function themeTitle($page_title) {
42
-        $page_title = isset($page_title)?$page_title:module()->getPageTitle();
43
-        return (isset($page_title))?cb()->getAppName().': '.strip_tags($page_title):"Admin Area";
42
+        $page_title = isset($page_title) ? $page_title : module()->getPageTitle();
43
+        return (isset($page_title)) ?cb()->getAppName().': '.strip_tags($page_title) : "Admin Area";
44 44
     }
45 45
 }
46 46
 
47
-if(!function_exists("getThemePath")) {
47
+if (!function_exists("getThemePath")) {
48 48
     function getThemePath($path = null) {
49
-        return getSetting("theme_path", "crudbooster::themes.adminlte").(($path)?".".$path:null);
49
+        return getSetting("theme_path", "crudbooster::themes.adminlte").(($path) ? ".".$path : null);
50 50
     }
51 51
 }
52 52
 
53 53
 // End Theme Helper
54 54
 
55
-if(!function_exists("isConfigCached")) {
55
+if (!function_exists("isConfigCached")) {
56 56
     function isConfigCached()
57 57
     {
58
-        if(env("APP_NAME")=="" || env("APP_NAME")==null) return true;
58
+        if (env("APP_NAME") == "" || env("APP_NAME") == null) return true;
59 59
         else return false;
60 60
     }
61 61
 }
62 62
 
63
-if(!function_exists("miscellanousSingleton")) {
63
+if (!function_exists("miscellanousSingleton")) {
64 64
     /**
65 65
      * @return \crocodicstudio\crudbooster\helpers\MiscellanousSingleton
66 66
      */
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
     }
70 70
 }
71 71
 
72
-if(!function_exists("makeReferalUrl")) {
72
+if (!function_exists("makeReferalUrl")) {
73 73
     function makeReferalUrl($name = null) {
74 74
         $ref = [];
75 75
         $ref['url'] = request()->fullUrl();
76 76
         $ref['name'] = $name;
77 77
         $md5Hash = md5(serialize($ref));
78 78
 
79
-        if($exist = \Illuminate\Support\Facades\Cache::get("refurl_".$md5Hash)) {
79
+        if ($exist = \Illuminate\Support\Facades\Cache::get("refurl_".$md5Hash)) {
80 80
             return $exist['id'];
81 81
         }
82 82
 
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
     }
89 89
 }
90 90
 
91
-if(!function_exists("getReferalUrl")) {
91
+if (!function_exists("getReferalUrl")) {
92 92
     function getReferalUrl($key = null) {
93
-        if(verifyReferalUrl()) {
93
+        if (verifyReferalUrl()) {
94 94
             $md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref"));
95 95
             $ref = \Illuminate\Support\Facades\Cache::get("refurl_".$md5hash);
96
-            if($key) {
96
+            if ($key) {
97 97
                 return @$ref[$key];
98 98
             } else {
99 99
                 return $ref;
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
     }
104 104
 }
105 105
 
106
-if(!function_exists("verifyReferalUrl")) {
106
+if (!function_exists("verifyReferalUrl")) {
107 107
     function verifyReferalUrl()
108 108
     {
109
-        if(request("ref")) {
110
-            if($md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref"))) {
109
+        if (request("ref")) {
110
+            if ($md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref"))) {
111 111
                 $ref = \Illuminate\Support\Facades\Cache::get("refurl_".$md5hash);
112
-                if(filter_var($ref['url'], FILTER_VALIDATE_URL)) {
112
+                if (filter_var($ref['url'], FILTER_VALIDATE_URL)) {
113 113
                     return true;
114 114
                 }
115 115
             }
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     }
119 119
 }
120 120
 
121
-if(!function_exists("putHtaccess")) {
121
+if (!function_exists("putHtaccess")) {
122 122
     function putHtaccess($stringToPut)
123 123
     {
124 124
         file_put_contents(base_path(".htaccess"), "\n".$stringToPut, FILE_APPEND);
@@ -126,13 +126,13 @@  discard block
 block discarded – undo
126 126
     }
127 127
 }
128 128
 
129
-if(!function_exists("checkHtaccess")) {
129
+if (!function_exists("checkHtaccess")) {
130 130
     function checkHtaccess($stringToCheck)
131 131
     {
132
-        if(file_exists(base_path(".htaccess")) && file_exists(public_path(".htaccess"))) {
132
+        if (file_exists(base_path(".htaccess")) && file_exists(public_path(".htaccess"))) {
133 133
             $htaccess = file_get_contents(base_path(".htaccess"));
134
-            $htaccess2= file_get_contents(public_path(".htaccess"));
135
-            if(\Illuminate\Support\Str::contains($htaccess, $stringToCheck) && \Illuminate\Support\Str::contains($htaccess2, $stringToCheck)) {
134
+            $htaccess2 = file_get_contents(public_path(".htaccess"));
135
+            if (\Illuminate\Support\Str::contains($htaccess, $stringToCheck) && \Illuminate\Support\Str::contains($htaccess2, $stringToCheck)) {
136 136
                 return true;
137 137
             }
138 138
         }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     }
142 142
 }
143 143
 
144
-if(!function_exists("setEnvironmentValue")) {
144
+if (!function_exists("setEnvironmentValue")) {
145 145
     function setEnvironmentValue(array $values)
146 146
     {
147 147
         $envFile = app()->environmentFilePath();
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 }
173 173
 
174 174
 
175
-if(!function_exists("cbLang")) {
175
+if (!function_exists("cbLang")) {
176 176
     /**
177 177
      * @param string $key
178 178
      * @param array $replace
@@ -184,17 +184,17 @@  discard block
 block discarded – undo
184 184
     }
185 185
 }
186 186
 
187
-if(!function_exists('rglob')) {
187
+if (!function_exists('rglob')) {
188 188
     function rglob($pattern, $flags = 0) {
189 189
         $files = glob($pattern, $flags);
190
-        foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
190
+        foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
191 191
             $files = array_merge($files, rglob($dir.'/'.basename($pattern), $flags));
192 192
         }
193 193
         return $files;
194 194
     }
195 195
 }
196 196
 
197
-if(!function_exists('convertPHPToMomentFormat')) {
197
+if (!function_exists('convertPHPToMomentFormat')) {
198 198
     function convertPHPToMomentFormat($format)
199 199
     {
200 200
         $replacements = [
@@ -241,13 +241,13 @@  discard block
 block discarded – undo
241 241
     }
242 242
 }
243 243
 
244
-if(!function_exists('slug')) {
244
+if (!function_exists('slug')) {
245 245
     function slug($string, $separator = '-') {
246 246
         return \Illuminate\Support\Str::slug($string, $separator);
247 247
     }
248 248
 }
249 249
 
250
-if(!function_exists('columnSingleton')) {
250
+if (!function_exists('columnSingleton')) {
251 251
     /**
252 252
      * @return \crocodicstudio\crudbooster\controllers\scaffolding\singletons\ColumnSingleton
253 253
      */
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
     }
257 257
 }
258 258
 
259
-if(!function_exists('cbHook'))
259
+if (!function_exists('cbHook'))
260 260
 {
261 261
     /**
262 262
      * @return crocodicstudio\crudbooster\hooks\CBHook
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
     }
269 269
 }
270 270
 
271
-if(!function_exists('getTypeHook'))
271
+if (!function_exists('getTypeHook'))
272 272
 {
273 273
     /**
274 274
      * @param string $type
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
     }
282 282
 }
283 283
 
284
-if(!function_exists('getPrimaryKey'))
284
+if (!function_exists('getPrimaryKey'))
285 285
 {
286 286
     function getPrimaryKey($table_name)
287 287
     {
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     }
290 290
 }
291 291
 
292
-if(!function_exists('cb'))
292
+if (!function_exists('cb'))
293 293
 {
294 294
     function cb()
295 295
     {
@@ -297,30 +297,30 @@  discard block
 block discarded – undo
297 297
     }
298 298
 }
299 299
 
300
-if(!function_exists("cbAssetPath")) {
300
+if (!function_exists("cbAssetPath")) {
301 301
     function cbAssetPath($path = null) {
302
-        return "cb_asset".(($path)?"/".$path:null);
302
+        return "cb_asset".(($path) ? "/".$path : null);
303 303
     }
304 304
 }
305
-if(!function_exists('cbAsset')) {
305
+if (!function_exists('cbAsset')) {
306 306
     function cbAsset($path, $secure = null) {
307 307
         return asset(cbAssetPath()."/".$path, $secure);
308 308
     }
309 309
 }
310 310
 
311
-if(!function_exists("cbConfig")) {
311
+if (!function_exists("cbConfig")) {
312 312
     function cbConfig($name, $default = null) {
313 313
         return config("crudbooster.".$name, $default);
314 314
     }
315 315
 }
316 316
 
317
-if(!function_exists("strRandom")) {
317
+if (!function_exists("strRandom")) {
318 318
     function strRandom($length = 5) {
319 319
         return \Illuminate\Support\Str::random($length);
320 320
     }
321 321
 }
322 322
 
323
-if(!function_exists('module')) {
323
+if (!function_exists('module')) {
324 324
     function module()
325 325
     {
326 326
         $module = new \crocodicstudio\crudbooster\helpers\Module();
@@ -328,27 +328,27 @@  discard block
 block discarded – undo
328 328
     }
329 329
 }
330 330
 
331
-if(!function_exists('getAdminLoginURL')) {
331
+if (!function_exists('getAdminLoginURL')) {
332 332
     function getAdminLoginURL()
333 333
     {
334 334
         return cb()->getAdminUrl("login");
335 335
     }
336 336
 }
337 337
 
338
-if(!function_exists('dummyPhoto')) {
338
+if (!function_exists('dummyPhoto')) {
339 339
     function dummyPhoto()
340 340
     {
341
-        return getSetting("dummy_photo","cb_asset/images/user8-128x128.jpg");
341
+        return getSetting("dummy_photo", "cb_asset/images/user8-128x128.jpg");
342 342
     }
343 343
 }
344 344
 
345
-if(!function_exists("str_limit")) {
345
+if (!function_exists("str_limit")) {
346 346
     function str_limit($string, $limit = 100, $end = "...") {
347 347
         return \Illuminate\Support\Str::limit($string, $limit, $end);
348 348
     }
349 349
 }
350 350
 
351
-if(!function_exists('extract_unit')) {	
351
+if (!function_exists('extract_unit')) {	
352 352
 	/*
353 353
 	Credits: Bit Repository
354 354
 	URL: http://www.bitrepository.com/extract-content-between-two-delimiters-with-php.html
@@ -373,14 +373,14 @@  discard block
 block discarded – undo
373 373
 |
374 374
 */
375 375
 
376
-if(!function_exists('putSetting')) {
376
+if (!function_exists('putSetting')) {
377 377
     function putSetting($key, $value)
378 378
     {
379
-        if(file_exists(storage_path('.cbconfig'))) {
379
+        if (file_exists(storage_path('.cbconfig'))) {
380 380
             $settings = file_get_contents(storage_path('.cbconfig'));
381 381
             $settings = decrypt($settings);
382 382
             $settings = unserialize($settings);
383
-        }else{
383
+        } else {
384 384
             $settings = [];
385 385
         }
386 386
 
@@ -394,31 +394,31 @@  discard block
 block discarded – undo
394 394
     }
395 395
 }
396 396
 
397
-if(!function_exists('getSetting')) {
397
+if (!function_exists('getSetting')) {
398 398
     function getSetting($key, $default = null)
399 399
     {
400
-        if($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) {
400
+        if ($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) {
401 401
             return $cache;
402 402
         }
403 403
 
404
-        if(file_exists(storage_path('.cbconfig'))) {
404
+        if (file_exists(storage_path('.cbconfig'))) {
405 405
             $settings = file_get_contents(storage_path('.cbconfig'));
406 406
             $settings = decrypt($settings);
407 407
             $settings = unserialize($settings);
408
-        }else{
408
+        } else {
409 409
             $settings = [];
410 410
         }
411 411
 
412
-        if(isset($settings[$key])) {
412
+        if (isset($settings[$key])) {
413 413
             \Illuminate\Support\Facades\Cache::forever("setting_".$key, $settings[$key]);
414
-            return $settings[$key]?:$default;
415
-        }else{
414
+            return $settings[$key] ?: $default;
415
+        } else {
416 416
             return $default;
417 417
         }
418 418
     }
419 419
 }
420 420
 
421
-if(!function_exists('timeAgo')) {
421
+if (!function_exists('timeAgo')) {
422 422
     function timeAgo($datetime_to, $datetime_from = null, $full = false)
423 423
     {
424 424
         $datetime_from = ($datetime_from) ?: date('Y-m-d H:i:s');
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
             }
450 450
         }
451 451
 
452
-        if (! $full) {
452
+        if (!$full) {
453 453
             $string = array_slice($string, 0, 1);
454 454
         }
455 455
 
@@ -457,22 +457,22 @@  discard block
 block discarded – undo
457 457
     }
458 458
 }
459 459
 
460
-if(!function_exists("array_map_r")) {
461
-    function array_map_r( $func, $arr )
460
+if (!function_exists("array_map_r")) {
461
+    function array_map_r($func, $arr)
462 462
     {
463 463
         $newArr = array();
464 464
 
465
-        foreach( $arr as $key => $value )
465
+        foreach ($arr as $key => $value)
466 466
         {
467 467
             $key = $func($key);
468
-            $newArr[ $key ] = ( is_array( $value ) ? array_map_r( $func, $value ) : ( is_array($func) ? call_user_func_array($func, $value) : $func( $value ) ) );
468
+            $newArr[$key] = (is_array($value) ? array_map_r($func, $value) : (is_array($func) ? call_user_func_array($func, $value) : $func($value)));
469 469
         }
470 470
 
471 471
         return $newArr;
472 472
     }
473 473
 }
474 474
 
475
-if(!function_exists("sanitizeXSS"))
475
+if (!function_exists("sanitizeXSS"))
476 476
 {
477 477
     function sanitizeXSS($value)
478 478
     {
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
     }
485 485
 }
486 486
 
487
-if(!function_exists("requestAll")) {
487
+if (!function_exists("requestAll")) {
488 488
     function requestAll() {
489 489
         $all = array_map_r("sanitizeXSS", request()->all());
490 490
         return $all;
@@ -493,22 +493,22 @@  discard block
 block discarded – undo
493 493
 
494 494
 
495 495
 
496
-if(!function_exists('getURLFormat')) {
496
+if (!function_exists('getURLFormat')) {
497 497
     function getURLFormat($name) {
498 498
         $url = request($name);
499
-        if(filter_var($url, FILTER_VALIDATE_URL)) {
499
+        if (filter_var($url, FILTER_VALIDATE_URL)) {
500 500
             return $url;
501
-        }else{
501
+        } else {
502 502
             return request()->url();
503 503
         }
504 504
     }
505 505
 }
506 506
 
507
-if(!function_exists('g')) {
507
+if (!function_exists('g')) {
508 508
     function g($name, $safe = true) {
509
-        if($safe == true) {
509
+        if ($safe == true) {
510 510
             $response = request($name);
511
-            if(is_string($response)) {
511
+            if (is_string($response)) {
512 512
                 $response = sanitizeXSS($response);
513 513
             }elseif (is_array($response)) {
514 514
                 array_walk_recursive($response, function(&$response) {
@@ -517,25 +517,25 @@  discard block
 block discarded – undo
517 517
             }
518 518
 
519 519
             return $response;
520
-        }else{
520
+        } else {
521 521
             return Request::get($name);
522 522
         }
523 523
     }
524 524
 }
525 525
 
526
-if(!function_exists('min_var_export')) {
526
+if (!function_exists('min_var_export')) {
527 527
     function min_var_export($input) {
528
-        if(is_array($input)) {
528
+        if (is_array($input)) {
529 529
             $buffer = [];
530
-            foreach($input as $key => $value)
530
+            foreach ($input as $key => $value)
531 531
                 $buffer[] = var_export($key, true)."=>".min_var_export($value);
532
-            return "[".implode(",",$buffer)."]";
532
+            return "[".implode(",", $buffer)."]";
533 533
         } else
534 534
             return var_export($input, true);
535 535
     }
536 536
 }
537 537
 
538
-if(!function_exists('rrmdir')) {
538
+if (!function_exists('rrmdir')) {
539 539
 	/*
540 540
 	* http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir
541 541
 	*/
Please login to merge, or discard this patch.
src/controllers/DeveloperMenusController.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
 
26 26
     public function getIndex() {
27 27
         $data = [];
28
-        return view($this->view.".index",$data);
28
+        return view($this->view.".index", $data);
29 29
     }
30 30
 
31 31
     public function getAdd() {
32 32
         $data = [];
33 33
         $data['form_title'] = "Add Menu";
34 34
         $data['form_url'] = route('DeveloperMenusControllerPostAddSave');
35
-        $data['modules'] = DB::table("cb_modules")->orderBy("name","asc")->get();
35
+        $data['modules'] = DB::table("cb_modules")->orderBy("name", "asc")->get();
36 36
         return view($this->view.".form", $data);
37 37
     }
38 38
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
         $data = [];
41 41
         $data['form_title'] = "Edit Menu";
42 42
         $data['form_url'] = cb()->getDeveloperUrl("menus/edit-save/".$id);
43
-        $data['modules'] = DB::table("cb_modules")->orderBy("name","asc")->get();
43
+        $data['modules'] = DB::table("cb_modules")->orderBy("name", "asc")->get();
44 44
         $data['row'] = cb()->find("cb_menus", $id);
45 45
         return view($this->view.".form", $data);
46 46
     }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             $menu['name'] = request('name');
54 54
             $menu['icon'] = request('icon');
55 55
             $menu['type'] = request('type');
56
-            if(request('type') == 'module') {
56
+            if (request('type') == 'module') {
57 57
                 $menu['cb_modules_id'] = request('cb_modules_id');
58 58
             }elseif (request('type') == 'url') {
59 59
                 $menu['path'] = request('url_value');
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
             CacheHelper::forgetGroup("sidebar_menu");
69 69
 
70
-            return cb()->redirect(route("DeveloperMenusControllerGetIndex"),"The menu has been added!","success");
70
+            return cb()->redirect(route("DeveloperMenusControllerGetIndex"), "The menu has been added!", "success");
71 71
 
72 72
         } catch (CBValidationException $e) {
73 73
             return cb()->redirectBack($e->getMessage());
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             $menu['name'] = request('name');
83 83
             $menu['icon'] = request('icon');
84 84
             $menu['type'] = request('type');
85
-            if(request('type') == 'module') {
85
+            if (request('type') == 'module') {
86 86
                 $menu['cb_modules_id'] = request('cb_modules_id');
87 87
             }elseif (request('type') == 'url') {
88 88
                 $menu['path'] = request('url_value');
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
             } elseif (request("type") == "empty") {
92 92
                 $menu['path'] = "javascript:void(0);";
93 93
             }
94
-            DB::table("cb_menus")->where("id",$id)->update($menu);
94
+            DB::table("cb_menus")->where("id", $id)->update($menu);
95 95
 
96 96
             CacheHelper::forgetGroup("sidebar_menu");
97 97
 
98
-            return cb()->redirect(route("DeveloperMenusControllerGetIndex"),"The menu has been saved!","success");
98
+            return cb()->redirect(route("DeveloperMenusControllerGetIndex"), "The menu has been saved!", "success");
99 99
 
100 100
         } catch (CBValidationException $e) {
101 101
             return cb()->redirectBack($e->getMessage());
@@ -108,20 +108,20 @@  discard block
 block discarded – undo
108 108
 
109 109
             $menus = request('menus');
110 110
             $menus = json_decode($menus, true);
111
-            if($menus) {
111
+            if ($menus) {
112 112
                 $menus = $menus[0];
113
-                if($menus) {
114
-                    foreach($menus as $i=>$menu) {
113
+                if ($menus) {
114
+                    foreach ($menus as $i=>$menu) {
115 115
                         $id = $menu['id'];
116
-                        cb()->update("cb_menus",$id,["sort_number"=>$i,'parent_cb_menus_id'=>null]);
117
-                        if($menu['children'][0]) {
118
-                            foreach($menu['children'][0] as $ii=>$sub) {
116
+                        cb()->update("cb_menus", $id, ["sort_number"=>$i, 'parent_cb_menus_id'=>null]);
117
+                        if ($menu['children'][0]) {
118
+                            foreach ($menu['children'][0] as $ii=>$sub) {
119 119
                                 $id = $sub['id'];
120
-                                cb()->update("cb_menus",$id,["sort_number"=>$ii,"parent_cb_menus_id"=>$menu['id']]);
121
-                                if($sub['children'][0]) {
122
-                                    foreach($sub['children'][0] as $iii=>$subsub) {
120
+                                cb()->update("cb_menus", $id, ["sort_number"=>$ii, "parent_cb_menus_id"=>$menu['id']]);
121
+                                if ($sub['children'][0]) {
122
+                                    foreach ($sub['children'][0] as $iii=>$subsub) {
123 123
                                         $id = $subsub['id'];
124
-                                        cb()->update("cb_menus",$id,["sort_number"=>$iii,"parent_cb_menus_id"=>$sub['id']]);
124
+                                        cb()->update("cb_menus", $id, ["sort_number"=>$iii, "parent_cb_menus_id"=>$sub['id']]);
125 125
                                     }
126 126
                                 }
127 127
                             }
@@ -132,20 +132,20 @@  discard block
 block discarded – undo
132 132
 
133 133
             CacheHelper::forgetGroup("sidebar_menu");
134 134
 
135
-            return response()->json(['api_status'=>1,'api_message'=>'success']);
135
+            return response()->json(['api_status'=>1, 'api_message'=>'success']);
136 136
 
137 137
         } catch (CBValidationException $e) {
138
-            return response()->json(['api_status'=>0,'api_message'=>$e->getMessage()]);
138
+            return response()->json(['api_status'=>0, 'api_message'=>$e->getMessage()]);
139 139
         }
140 140
     }
141 141
 
142 142
     public function getDelete($id) {
143
-        DB::table("cb_menus")->where("id",$id)->delete();
143
+        DB::table("cb_menus")->where("id", $id)->delete();
144 144
         DB::table("cb_role_privileges")->where("cb_menus_id", $id)->delete();
145 145
 
146 146
         CacheHelper::forgetGroup("sidebar_menu");
147 147
 
148
-        return cb()->redirectBack("The menu has been deleted!","success");
148
+        return cb()->redirectBack("The menu has been deleted!", "success");
149 149
     }
150 150
 
151 151
 }
152 152
\ No newline at end of file
Please login to merge, or discard this patch.
src/helpers/SidebarMenus.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
     private function assignToModel($menu) {
18 18
         $model = new SidebarModel();
19 19
         $model->setId($menu->id);
20
-        if($menu->type == "url") {
20
+        if ($menu->type == "url") {
21 21
             $model->setUrl($menu->path);
22 22
             $model->setIcon($menu->icon);
23 23
             $model->setName($menu->name);
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
             $model->setName($menu->name);
45 45
 		}
46 46
 
47
-        if(request()->is($model->getBasepath()."*")) {
47
+        if (request()->is($model->getBasepath()."*")) {
48 48
             $model->setIsActive(true);
49
-        }else{
49
+        } else {
50 50
             $model->setIsActive(false);
51 51
         }
52 52
 
@@ -55,22 +55,22 @@  discard block
 block discarded – undo
55 55
 
56 56
     private function loadData($parent_id = null) {
57 57
         $menus = DB::table("cb_menus");
58
-        if($parent_id) {
59
-            $menus->where("parent_cb_menus_id",$parent_id);
60
-        }else{
58
+        if ($parent_id) {
59
+            $menus->where("parent_cb_menus_id", $parent_id);
60
+        } else {
61 61
             $menus->whereNull("parent_cb_menus_id");
62 62
         }
63
-        return $menus->orderBy("sort_number","asc")->get();
63
+        return $menus->orderBy("sort_number", "asc")->get();
64 64
     }
65 65
 
66 66
     private function rolePrivilege($cb_roles_id, $cb_menus_id) {
67
-        return cb()->find("cb_role_privileges",['cb_roles_id'=>$cb_roles_id,'cb_menus_id'=>$cb_menus_id]);
67
+        return cb()->find("cb_role_privileges", ['cb_roles_id'=>$cb_roles_id, 'cb_menus_id'=>$cb_menus_id]);
68 68
     }
69 69
 
70
-    private function checkPrivilege($roles_id,$menu) {
71
-        if($roles_id) {
70
+    private function checkPrivilege($roles_id, $menu) {
71
+        if ($roles_id) {
72 72
             $privilege = $this->rolePrivilege($roles_id, $menu->id);
73
-            if($privilege && !$privilege->can_browse) {
73
+            if ($privilege && !$privilege->can_browse) {
74 74
                 return false;
75 75
             }
76 76
         }
@@ -79,30 +79,30 @@  discard block
 block discarded – undo
79 79
     }
80 80
 
81 81
     public function all($withPrivilege = true) {
82
-        $roles_id = ($withPrivilege)?cb()->session()->roleId():null;
82
+        $roles_id = ($withPrivilege) ?cb()->session()->roleId() : null;
83 83
         $idHash = "menuUser".$roles_id.auth()->id();
84
-        if($menu = CacheHelper::getItemInGroup($idHash,"sidebar_menu")) return $menu;
84
+        if ($menu = CacheHelper::getItemInGroup($idHash, "sidebar_menu")) return $menu;
85 85
 
86 86
         $menus = $this->loadData();
87 87
         $result = [];
88
-        foreach($menus as $menu) {
88
+        foreach ($menus as $menu) {
89 89
 
90
-            if($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) continue;
90
+            if ($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) continue;
91 91
 
92 92
             $sidebarModel = $this->assignToModel($menu);
93
-            if($menus2 = $this->loadData($menu->id)) {
93
+            if ($menus2 = $this->loadData($menu->id)) {
94 94
                 $sub1 = [];
95 95
                 foreach ($menus2 as $menu2) {
96 96
 
97
-                    if($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) continue;
97
+                    if ($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) continue;
98 98
 
99 99
                     $sidebarModel2 = $this->assignToModel($menu2);
100 100
 
101
-                    if($menus3 = $this->loadData($menu2->id)) {
101
+                    if ($menus3 = $this->loadData($menu2->id)) {
102 102
                         $sub2 = [];
103 103
                         foreach ($menus3 as $menu3) {
104 104
 
105
-                            if($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) continue;
105
+                            if ($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) continue;
106 106
 
107 107
                             $sidebarModel3 = $this->assignToModel($menu3);
108 108
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
             $result[] = $sidebarModel;
118 118
         }
119 119
 
120
-        CacheHelper::putInGroup($idHash, $result,"sidebar_menu", 3600);
120
+        CacheHelper::putInGroup($idHash, $result, "sidebar_menu", 3600);
121 121
         return $result;
122 122
     }
123 123
 
Please login to merge, or discard this patch.