Passed
Push — master ( ab23d3...456c2a )
by Ferry
05:06
created
src/helpers/SchemaHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,6 +16,6 @@
 block discarded – undo
16 16
     public static function hasColumn($table, $column)
17 17
     {
18 18
         $columns = cb()->listAllColumns($table);
19
-        return in_array($column,$columns);
19
+        return in_array($column, $columns);
20 20
     }
21 21
 }
22 22
\ No newline at end of file
Please login to merge, or discard this patch.
src/helpers/CB.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     }
25 25
 
26 26
     public function getRoleByName($roleName) {
27
-        return $this->find("cb_roles",['name'=>$roleName]);
27
+        return $this->find("cb_roles", ['name'=>$roleName]);
28 28
     }
29 29
 
30 30
     public function fcm() {
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     }
41 41
 
42 42
     public function getDeveloperUrl($path = null) {
43
-        $path = ($path)?"/".trim($path,"/"):null;
43
+        $path = ($path) ? "/".trim($path, "/") : null;
44 44
         return url("developer/".getSetting("developer_path")).$path;
45 45
     }
46 46
 
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
     }
58 58
 
59 59
     public function getAdminPath() {
60
-        return getSetting("ADMIN_PATH","admin");
60
+        return getSetting("ADMIN_PATH", "admin");
61 61
     }
62 62
 
63 63
     public function getAdminUrl($path = null) {
64
-        $path = ($path)?"/".trim($path,"/"):null;
64
+        $path = ($path) ? "/".trim($path, "/") : null;
65 65
         return url($this->getAdminPath()).$path;
66 66
     }
67 67
 
68 68
     public function getAppName() {
69
-        return getSetting("APP_NAME", env("APP_NAME","CRUDBOOSTER"));
69
+        return getSetting("APP_NAME", env("APP_NAME", "CRUDBOOSTER"));
70 70
     }
71 71
 
72 72
     /**
@@ -80,16 +80,16 @@  discard block
 block discarded – undo
80 80
      */
81 81
     private function uploadFileProcess($filename, $extension, $file, $encrypt = true, $resize_width = null, $resize_height = null)
82 82
     {
83
-        if(in_array($extension,cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) {
83
+        if (in_array($extension, cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) {
84 84
             $file_path = cbConfig("UPLOAD_PATH_FORMAT");
85
-            $file_path = str_replace("{Y}",date('Y'), $file_path);
85
+            $file_path = str_replace("{Y}", date('Y'), $file_path);
86 86
             $file_path = str_replace("{m}", date('m'), $file_path);
87 87
             $file_path = str_replace("{d}", date("d"), $file_path);
88 88
 
89 89
             //Create Directory Base On Template
90 90
             Storage::makeDirectory($file_path);
91
-            Storage::put($file_path."/index.html"," ","public");
92
-            Storage::put($file_path."/.gitignore","!.gitignore","public");
91
+            Storage::put($file_path."/index.html", " ", "public");
92
+            Storage::put($file_path."/.gitignore", "!.gitignore", "public");
93 93
 
94 94
             if ($encrypt == true) {
95 95
                 $filename = md5(strRandom(5)).'.'.$extension;
@@ -97,17 +97,17 @@  discard block
 block discarded – undo
97 97
                 $filename = slug($filename, '_').'.'.$extension;
98 98
             }
99 99
 
100
-            if($resize_width || $resize_height) {
100
+            if ($resize_width || $resize_height) {
101 101
                 $this->resizeImage($file, $file_path.'/'.$filename, $resize_width, $resize_height);
102 102
                 return $file_path.'/'.$filename;
103
-            }else{
103
+            } else {
104 104
                 if (Storage::putFileAs($file_path, $file, $filename, 'public')) {
105 105
                     return $file_path.'/'.$filename;
106 106
                 } else {
107 107
                     throw new \Exception("Something went wrong, file can't upload!");
108 108
                 }
109 109
             }
110
-        }else{
110
+        } else {
111 111
             throw new \Exception("The file format is not allowed!");
112 112
         }
113 113
     }
@@ -123,16 +123,16 @@  discard block
 block discarded – undo
123 123
     {
124 124
         $fileData = base64_decode($base64_value);
125 125
         $mime_type = finfo_buffer(finfo_open(), $fileData, FILEINFO_MIME_TYPE);
126
-        if($mime_type) {
127
-            if($mime_type = explode('/', $mime_type)) {
126
+        if ($mime_type) {
127
+            if ($mime_type = explode('/', $mime_type)) {
128 128
                 $ext = $mime_type[1];
129
-                if($filename && $ext) {
129
+                if ($filename && $ext) {
130 130
                     return $this->uploadFileProcess($filename, $ext, $fileData, $encrypt, $resize_width, $resize_height);
131 131
                 }
132
-            }else {
132
+            } else {
133 133
                 throw new \Exception("Mime type not found");
134 134
             }
135
-        }else{
135
+        } else {
136 136
             throw new \Exception("Mime type not found");
137 137
         }
138 138
     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
             $filename = $file->getClientOriginalName();
153 153
             $ext = strtolower($file->getClientOriginalExtension());
154 154
 
155
-            if($filename && $ext) {
155
+            if ($filename && $ext) {
156 156
                 return $this->uploadFileProcess($filename, $ext, $file, $encrypt, $resize_width, $resize_height);
157 157
             }
158 158
 
@@ -187,29 +187,29 @@  discard block
 block discarded – undo
187 187
             if ($resize_width && $resize_height) {
188 188
                 $img->fit($resize_width, $resize_height);
189 189
 
190
-            } elseif ($resize_width && ! $resize_height) {
190
+            } elseif ($resize_width && !$resize_height) {
191 191
 
192
-                $img->resize($resize_width, null, function ($constraint) {
192
+                $img->resize($resize_width, null, function($constraint) {
193 193
                     $constraint->aspectRatio();
194 194
                 });
195 195
 
196
-            } elseif (! $resize_width && $resize_height) {
196
+            } elseif (!$resize_width && $resize_height) {
197 197
 
198
-                $img->resize(null, $resize_height, function ($constraint) {
198
+                $img->resize(null, $resize_height, function($constraint) {
199 199
                     $constraint->aspectRatio();
200 200
                 });
201 201
 
202 202
             } else {
203 203
 
204 204
                 if ($img->width() > cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES")) {
205
-                    $img->resize(cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES"), null, function ($constraint) {
205
+                    $img->resize(cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES"), null, function($constraint) {
206 206
                         $constraint->aspectRatio();
207 207
                     });
208 208
                 }
209 209
             }
210 210
 
211 211
             Storage::put($fullFilePath, $img, 'public');
212
-        }else{
212
+        } else {
213 213
             throw new \Exception("The file format is not allowed!");
214 214
         }
215 215
     }
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
     {
234 234
         if (is_array($id)) {
235 235
             $idHash = md5("find".$table.serialize($id));
236
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
236
+            if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
237 237
 
238 238
             $first = DB::table($table);
239 239
             foreach ($id as $k => $v) {
@@ -241,15 +241,15 @@  discard block
 block discarded – undo
241 241
             }
242 242
 
243 243
             $data = $first->first();
244
-            miscellanousSingleton()->setData($idHash,$data);
244
+            miscellanousSingleton()->setData($idHash, $data);
245 245
             return $data;
246 246
         } else {
247 247
             $idHash = md5("find".$table.$id);
248
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
248
+            if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
249 249
 
250 250
             $pk = $this->pk($table);
251 251
             $data = DB::table($table)->where($pk, $id)->first();
252
-            miscellanousSingleton()->setData($idHash,$data);
252
+            miscellanousSingleton()->setData($idHash, $data);
253 253
             return $data;
254 254
         }
255 255
     }
@@ -264,30 +264,30 @@  discard block
 block discarded – undo
264 264
         $data = [];
265 265
         $idHash = null;
266 266
 
267
-        if(is_array($conditionOrCallback)) {
267
+        if (is_array($conditionOrCallback)) {
268 268
             $idHash = md5("findAll".$table.serialize($conditionOrCallback));
269
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
269
+            if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
270 270
 
271 271
             $data = DB::table($table)->where($conditionOrCallback)->get();
272 272
         } elseif (is_callable($conditionOrCallback)) {
273 273
             $idHash = "findAll".$table.spl_object_hash($conditionOrCallback);
274
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
274
+            if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
275 275
 
276 276
             $data = DB::table($table);
277 277
             $data = call_user_func($conditionOrCallback, $data);
278 278
             $data = $data->get();
279 279
         } else {
280 280
             $idHash = md5("findAll".$table.$conditionOrCallback);
281
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
281
+            if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
282 282
 
283 283
             $data = DB::table($table);
284
-            if($conditionOrCallback) {
284
+            if ($conditionOrCallback) {
285 285
                 $data = $data->whereRaw($conditionOrCallback);
286 286
             }
287 287
             $data = $data->get();
288 288
         }
289 289
 
290
-        if($idHash && $data) {
290
+        if ($idHash && $data) {
291 291
             miscellanousSingleton()->setData($idHash, $data);
292 292
         }
293 293
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
     public function listAllTable()
298 298
     {
299 299
         $idHash = md5("listAllTable");
300
-        if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
300
+        if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
301 301
         $data = DB::connection()->getDoctrineSchemaManager()->listTableNames();
302 302
         miscellanousSingleton()->setData($idHash, $data);
303 303
         return $data;
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
     public function listAllColumns($table)
307 307
     {
308 308
         $idHash = md5("listAllColumns".$table);
309
-        if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
309
+        if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
310 310
         $data = Schema::getColumnListing($table);
311 311
         miscellanousSingleton()->setData($idHash, $data);
312 312
         return $data;
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
         $validator = Validator::make($input_arr, $rules, $messages);
375 375
         if ($validator->fails()) {
376 376
             $message = $validator->errors()->all();
377
-            throw new CBValidationException(implode("; ",$message));
377
+            throw new CBValidationException(implode("; ", $message));
378 378
         }
379 379
     }
380 380
 
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
     public function findPrimaryKey($table)
387 387
     {
388 388
         $pk = DB::getDoctrineSchemaManager()->listTableDetails($table)->getPrimaryKey();
389
-        if(!$pk) {
389
+        if (!$pk) {
390 390
             return null;
391 391
         }
392 392
         return $pk->getColumns()[0];
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
             $string_parameters_array = explode('&', $string_parameters);
436 436
             foreach ($string_parameters_array as $s) {
437 437
                 $part = explode('=', $s);
438
-                if(isset($part[0]) && isset($part[1])) {
438
+                if (isset($part[0]) && isset($part[1])) {
439 439
                     $name = htmlspecialchars(urldecode($part[0]));
440 440
                     $name = strip_tags($name);
441 441
                     $value = htmlspecialchars(urldecode($part[1]));
@@ -452,16 +452,16 @@  discard block
 block discarded – undo
452 452
 
453 453
 
454 454
     public function routeGet($prefix, $controller) {
455
-        $alias = str_replace("@"," ", $controller);
455
+        $alias = str_replace("@", " ", $controller);
456 456
         $alias = ucwords($alias);
457
-        $alias = str_replace(" ","",$alias);
457
+        $alias = str_replace(" ", "", $alias);
458 458
         Route::get($prefix, ['uses' => $controller, 'as' => $alias]);
459 459
     }
460 460
 
461 461
     public function routePost($prefix, $controller) {
462
-        $alias = str_replace("@"," ", $controller);
462
+        $alias = str_replace("@", " ", $controller);
463 463
         $alias = ucwords($alias);
464
-        $alias = str_replace(" ","",$alias);
464
+        $alias = str_replace(" ", "", $alias);
465 465
         Route::post($prefix, ['uses' => $controller, 'as' => $alias]);
466 466
     }
467 467
 
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 
495 495
         $prefix = trim($prefix, '/').'/';
496 496
 
497
-        if(substr($controller,0,1) != "\\") {
497
+        if (substr($controller, 0, 1) != "\\") {
498 498
             $controller = "\App\Http\Controllers\\".$controller;
499 499
         }
500 500
 
Please login to merge, or discard this patch.
src/helpers/Helper.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!function_exists("miscellanousSingleton")) {
3
+if (!function_exists("miscellanousSingleton")) {
4 4
     /**
5 5
      * @return \crocodicstudio\crudbooster\helpers\MiscellanousSingleton
6 6
      */
@@ -9,14 +9,14 @@  discard block
 block discarded – undo
9 9
     }
10 10
 }
11 11
 
12
-if(!function_exists("makeReferalUrl")) {
12
+if (!function_exists("makeReferalUrl")) {
13 13
     function makeReferalUrl($name = null) {
14 14
         $ref = [];
15 15
         $ref['url'] = request()->fullUrl();
16 16
         $ref['name'] = $name;
17 17
         $md5Hash = md5(serialize($ref));
18 18
 
19
-        if($exist = \Illuminate\Support\Facades\Cache::get("refurl_".$md5Hash)) {
19
+        if ($exist = \Illuminate\Support\Facades\Cache::get("refurl_".$md5Hash)) {
20 20
             return $exist['id'];
21 21
         }
22 22
 
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
     }
29 29
 }
30 30
 
31
-if(!function_exists("getReferalUrl")) {
31
+if (!function_exists("getReferalUrl")) {
32 32
     function getReferalUrl($key = null) {
33
-        if(verifyReferalUrl()) {
33
+        if (verifyReferalUrl()) {
34 34
             $md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref"));
35 35
             $ref = \Illuminate\Support\Facades\Cache::get("refurl_".$md5hash);
36
-            if($key) {
36
+            if ($key) {
37 37
                 return @$ref[$key];
38 38
             } else {
39 39
                 return $ref;
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
     }
44 44
 }
45 45
 
46
-if(!function_exists("verifyReferalUrl")) {
46
+if (!function_exists("verifyReferalUrl")) {
47 47
     function verifyReferalUrl()
48 48
     {
49
-        if(request("ref")) {
50
-            if($md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref"))) {
49
+        if (request("ref")) {
50
+            if ($md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref"))) {
51 51
                 $ref = \Illuminate\Support\Facades\Cache::get("refurl_".$md5hash);
52
-                if(filter_var($ref['url'], FILTER_VALIDATE_URL)) {
52
+                if (filter_var($ref['url'], FILTER_VALIDATE_URL)) {
53 53
                     return true;
54 54
                 }
55 55
             }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     }
59 59
 }
60 60
 
61
-if(!function_exists("putHtaccess")) {
61
+if (!function_exists("putHtaccess")) {
62 62
     function putHtaccess($stringToPut)
63 63
     {
64 64
         file_put_contents(base_path(".htaccess"), "\n".$stringToPut, FILE_APPEND);
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
     }
67 67
 }
68 68
 
69
-if(!function_exists("checkHtaccess")) {
69
+if (!function_exists("checkHtaccess")) {
70 70
     function checkHtaccess($stringToCheck)
71 71
     {
72
-        if(file_exists(base_path(".htaccess")) && file_exists(public_path(".htaccess"))) {
72
+        if (file_exists(base_path(".htaccess")) && file_exists(public_path(".htaccess"))) {
73 73
             $htaccess = file_get_contents(base_path(".htaccess"));
74
-            $htaccess2= file_get_contents(public_path(".htaccess"));
75
-            if(\Illuminate\Support\Str::contains($htaccess, $stringToCheck) && \Illuminate\Support\Str::contains($htaccess2, $stringToCheck)) {
74
+            $htaccess2 = file_get_contents(public_path(".htaccess"));
75
+            if (\Illuminate\Support\Str::contains($htaccess, $stringToCheck) && \Illuminate\Support\Str::contains($htaccess2, $stringToCheck)) {
76 76
                 return true;
77 77
             }
78 78
         }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
     }
82 82
 }
83 83
 
84
-if(!function_exists("setEnvironmentValue")) {
84
+if (!function_exists("setEnvironmentValue")) {
85 85
     function setEnvironmentValue(array $values)
86 86
     {
87 87
         $envFile = app()->environmentFilePath();
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 }
113 113
 
114 114
 
115
-if(!function_exists("cbLang")) {
115
+if (!function_exists("cbLang")) {
116 116
     /**
117 117
      * @param string $key
118 118
      * @param array $replace
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
     }
125 125
 }
126 126
 
127
-if(!function_exists('rglob')) {
127
+if (!function_exists('rglob')) {
128 128
     function rglob($pattern, $flags = 0) {
129 129
         $files = glob($pattern, $flags);
130
-        foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
130
+        foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
131 131
             $files = array_merge($files, rglob($dir.'/'.basename($pattern), $flags));
132 132
         }
133 133
         return $files;
134 134
     }
135 135
 }
136 136
 
137
-if(!function_exists('convertPHPToMomentFormat')) {
137
+if (!function_exists('convertPHPToMomentFormat')) {
138 138
     function convertPHPToMomentFormat($format)
139 139
     {
140 140
         $replacements = [
@@ -181,13 +181,13 @@  discard block
 block discarded – undo
181 181
     }
182 182
 }
183 183
 
184
-if(!function_exists('slug')) {
184
+if (!function_exists('slug')) {
185 185
     function slug($string, $separator = '-') {
186 186
         return \Illuminate\Support\Str::slug($string, $separator);
187 187
     }
188 188
 }
189 189
 
190
-if(!function_exists('columnSingleton')) {
190
+if (!function_exists('columnSingleton')) {
191 191
     /**
192 192
      * @return \crocodicstudio\crudbooster\controllers\scaffolding\singletons\ColumnSingleton
193 193
      */
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
     }
197 197
 }
198 198
 
199
-if(!function_exists('cbHook'))
199
+if (!function_exists('cbHook'))
200 200
 {
201 201
     /**
202 202
      * @return crocodicstudio\crudbooster\hooks\CBHook
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
     }
209 209
 }
210 210
 
211
-if(!function_exists('getTypeHook'))
211
+if (!function_exists('getTypeHook'))
212 212
 {
213 213
     /**
214 214
      * @param string $type
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
     }
222 222
 }
223 223
 
224
-if(!function_exists('getPrimaryKey'))
224
+if (!function_exists('getPrimaryKey'))
225 225
 {
226 226
     function getPrimaryKey($table_name)
227 227
     {
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
     }
230 230
 }
231 231
 
232
-if(!function_exists('cb'))
232
+if (!function_exists('cb'))
233 233
 {
234 234
     function cb()
235 235
     {
@@ -237,25 +237,25 @@  discard block
 block discarded – undo
237 237
     }
238 238
 }
239 239
 
240
-if(!function_exists('cbAsset')) {
240
+if (!function_exists('cbAsset')) {
241 241
     function cbAsset($path, $secure = null) {
242 242
         return asset("cb_asset/".$path, $secure);
243 243
     }
244 244
 }
245 245
 
246
-if(!function_exists("cbConfig")) {
246
+if (!function_exists("cbConfig")) {
247 247
     function cbConfig($name, $default = null) {
248 248
         return config("crudbooster.".$name, $default);
249 249
     }
250 250
 }
251 251
 
252
-if(!function_exists("strRandom")) {
252
+if (!function_exists("strRandom")) {
253 253
     function strRandom($length = 5) {
254 254
         return \Illuminate\Support\Str::random($length);
255 255
     }
256 256
 }
257 257
 
258
-if(!function_exists('module')) {
258
+if (!function_exists('module')) {
259 259
     function module()
260 260
     {
261 261
         $module = new \crocodicstudio\crudbooster\helpers\Module();
@@ -263,21 +263,21 @@  discard block
 block discarded – undo
263 263
     }
264 264
 }
265 265
 
266
-if(!function_exists('getAdminLoginURL')) {
266
+if (!function_exists('getAdminLoginURL')) {
267 267
     function getAdminLoginURL()
268 268
     {
269 269
         return cb()->getAdminUrl("login");
270 270
     }
271 271
 }
272 272
 
273
-if(!function_exists('dummyPhoto')) {
273
+if (!function_exists('dummyPhoto')) {
274 274
     function dummyPhoto()
275 275
     {
276 276
         return cbConfig("DUMMY_PHOTO");
277 277
     }
278 278
 }
279 279
 
280
-if(!function_exists('extract_unit')) {	
280
+if (!function_exists('extract_unit')) {	
281 281
 	/*
282 282
 	Credits: Bit Repository
283 283
 	URL: http://www.bitrepository.com/extract-content-between-two-delimiters-with-php.html
@@ -302,14 +302,14 @@  discard block
 block discarded – undo
302 302
 |
303 303
 */
304 304
 
305
-if(!function_exists('putSetting')) {
305
+if (!function_exists('putSetting')) {
306 306
     function putSetting($key, $value)
307 307
     {
308
-        if(file_exists(storage_path('.cbconfig'))) {
308
+        if (file_exists(storage_path('.cbconfig'))) {
309 309
             $settings = file_get_contents(storage_path('.cbconfig'));
310 310
             $settings = decrypt($settings);
311 311
             $settings = unserialize($settings);
312
-        }else{
312
+        } else {
313 313
             $settings = [];
314 314
         }
315 315
 
@@ -323,31 +323,31 @@  discard block
 block discarded – undo
323 323
     }
324 324
 }
325 325
 
326
-if(!function_exists('getSetting')) {
326
+if (!function_exists('getSetting')) {
327 327
     function getSetting($key, $default = null)
328 328
     {
329
-        if($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) {
329
+        if ($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) {
330 330
             return $cache;
331 331
         }
332 332
 
333
-        if(file_exists(storage_path('.cbconfig'))) {
333
+        if (file_exists(storage_path('.cbconfig'))) {
334 334
             $settings = file_get_contents(storage_path('.cbconfig'));
335 335
             $settings = decrypt($settings);
336 336
             $settings = unserialize($settings);
337
-        }else{
337
+        } else {
338 338
             $settings = [];
339 339
         }
340 340
 
341
-        if(isset($settings[$key])) {
341
+        if (isset($settings[$key])) {
342 342
             \Illuminate\Support\Facades\Cache::forever("setting_".$key, $settings[$key]);
343
-            return $settings[$key]?:$default;
344
-        }else{
343
+            return $settings[$key] ?: $default;
344
+        } else {
345 345
             return $default;
346 346
         }
347 347
     }
348 348
 }
349 349
 
350
-if(!function_exists('timeAgo')) {
350
+if (!function_exists('timeAgo')) {
351 351
     function timeAgo($datetime_to, $datetime_from = null, $full = false)
352 352
     {
353 353
         $datetime_from = ($datetime_from) ?: date('Y-m-d H:i:s');
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
             }
379 379
         }
380 380
 
381
-        if (! $full) {
381
+        if (!$full) {
382 382
             $string = array_slice($string, 0, 1);
383 383
         }
384 384
 
@@ -386,22 +386,22 @@  discard block
 block discarded – undo
386 386
     }
387 387
 }
388 388
 
389
-if(!function_exists("array_map_r")) {
390
-    function array_map_r( $func, $arr )
389
+if (!function_exists("array_map_r")) {
390
+    function array_map_r($func, $arr)
391 391
     {
392 392
         $newArr = array();
393 393
 
394
-        foreach( $arr as $key => $value )
394
+        foreach ($arr as $key => $value)
395 395
         {
396 396
             $key = $func($key);
397
-            $newArr[ $key ] = ( is_array( $value ) ? array_map_r( $func, $value ) : ( is_array($func) ? call_user_func_array($func, $value) : $func( $value ) ) );
397
+            $newArr[$key] = (is_array($value) ? array_map_r($func, $value) : (is_array($func) ? call_user_func_array($func, $value) : $func($value)));
398 398
         }
399 399
 
400 400
         return $newArr;
401 401
     }
402 402
 }
403 403
 
404
-if(!function_exists("sanitizeXSS"))
404
+if (!function_exists("sanitizeXSS"))
405 405
 {
406 406
     function sanitizeXSS($value)
407 407
     {
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
     }
414 414
 }
415 415
 
416
-if(!function_exists("requestAll")) {
416
+if (!function_exists("requestAll")) {
417 417
     function requestAll() {
418 418
         $all = array_map_r("sanitizeXSS", request()->all());
419 419
         return $all;
@@ -422,22 +422,22 @@  discard block
 block discarded – undo
422 422
 
423 423
 
424 424
 
425
-if(!function_exists('getURLFormat')) {
425
+if (!function_exists('getURLFormat')) {
426 426
     function getURLFormat($name) {
427 427
         $url = request($name);
428
-        if(filter_var($url, FILTER_VALIDATE_URL)) {
428
+        if (filter_var($url, FILTER_VALIDATE_URL)) {
429 429
             return $url;
430
-        }else{
430
+        } else {
431 431
             return request()->url();
432 432
         }
433 433
     }
434 434
 }
435 435
 
436
-if(!function_exists('g')) {
436
+if (!function_exists('g')) {
437 437
     function g($name, $safe = true) {
438
-        if($safe == true) {
438
+        if ($safe == true) {
439 439
             $response = request($name);
440
-            if(is_string($response)) {
440
+            if (is_string($response)) {
441 441
                 $response = sanitizeXSS($response);
442 442
             }elseif (is_array($response)) {
443 443
                 array_walk_recursive($response, function(&$response) {
@@ -446,25 +446,25 @@  discard block
 block discarded – undo
446 446
             }
447 447
 
448 448
             return $response;
449
-        }else{
449
+        } else {
450 450
             return Request::get($name);
451 451
         }
452 452
     }
453 453
 }
454 454
 
455
-if(!function_exists('min_var_export')) {
455
+if (!function_exists('min_var_export')) {
456 456
     function min_var_export($input) {
457
-        if(is_array($input)) {
457
+        if (is_array($input)) {
458 458
             $buffer = [];
459
-            foreach($input as $key => $value)
459
+            foreach ($input as $key => $value)
460 460
                 $buffer[] = var_export($key, true)."=>".min_var_export($value);
461
-            return "[".implode(",",$buffer)."]";
461
+            return "[".implode(",", $buffer)."]";
462 462
         } else
463 463
             return var_export($input, true);
464 464
     }
465 465
 }
466 466
 
467
-if(!function_exists('rrmdir')) {
467
+if (!function_exists('rrmdir')) {
468 468
 	/*
469 469
 	* http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir
470 470
 	*/
Please login to merge, or discard this patch.
src/helpers/Module.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -26,17 +26,17 @@  discard block
 block discarded – undo
26 26
         try {
27 27
             $routeArray = request()->route()->getAction();
28 28
             $this->controller = class_basename($routeArray['controller']);
29
-            $this->controller = strtok($this->controller,"@");
29
+            $this->controller = strtok($this->controller, "@");
30 30
 
31 31
             $className = "\\".$routeArray["namespace"]."\\".$this->controller;
32
-            if(class_exists($className)) {
33
-                $this->module = cb()->find("cb_modules",["controller"=>$this->controller]);
34
-                if($this->module) {
32
+            if (class_exists($className)) {
33
+                $this->module = cb()->find("cb_modules", ["controller"=>$this->controller]);
34
+                if ($this->module) {
35 35
                     $this->controller_class = new $className();
36
-                    $this->menu = cb()->find("cb_menus",["cb_modules_id"=>$this->module->id]);
37
-                    $this->menu = (!$this->menu)?cb()->find("cb_menus",["type"=>"path","path"=>request()->segment(2)]):$this->menu;
38
-                    if($this->menu) {
39
-                        $this->privilege = cb()->find("cb_role_privileges",[
36
+                    $this->menu = cb()->find("cb_menus", ["cb_modules_id"=>$this->module->id]);
37
+                    $this->menu = (!$this->menu) ?cb()->find("cb_menus", ["type"=>"path", "path"=>request()->segment(2)]) : $this->menu;
38
+                    if ($this->menu) {
39
+                        $this->privilege = cb()->find("cb_role_privileges", [
40 40
                            "cb_menus_id"=>$this->menu->id,
41 41
                            "cb_roles_id"=>cb()->session()->roleId()
42 42
                         ]);
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
     }
58 58
 
59 59
     public function getData($key) {
60
-        if($this->controller_class) {
60
+        if ($this->controller_class) {
61 61
             $value = $this->controller_class->getData($key);
62
-            if(isset($value)) {
62
+            if (isset($value)) {
63 63
                 return $value;
64 64
             }
65 65
         }
@@ -70,128 +70,128 @@  discard block
 block discarded – undo
70 70
      * @return CBController
71 71
      */
72 72
     public function getController() {
73
-        return ($this->controller_class)?$this->controller_class:null;
73
+        return ($this->controller_class) ? $this->controller_class : null;
74 74
     }
75 75
 
76 76
     public function getPageTitle()
77 77
     {
78
-        return ($this->controller_class)?$this->controller_class->getData("page_title")?:cb()->getAppName():null;
78
+        return ($this->controller_class) ? $this->controller_class->getData("page_title") ?: cb()->getAppName() : null;
79 79
     }
80 80
 
81 81
     public function getTable()
82 82
     {
83
-        return ($this->controller_class)?$this->controller_class->getData("table"):null;
83
+        return ($this->controller_class) ? $this->controller_class->getData("table") : null;
84 84
     }
85 85
 
86 86
     public function getPageIcon()
87 87
     {
88
-        return ($this->controller_class)?$this->controller_class->getData('page_icon')?:"fa fa-bars":null;
88
+        return ($this->controller_class) ? $this->controller_class->getData('page_icon') ?: "fa fa-bars" : null;
89 89
     }
90 90
 
91 91
     public function canBrowse() {
92
-        if($this->privilege) {
93
-            if($this->privilege->can_browse) return true;
92
+        if ($this->privilege) {
93
+            if ($this->privilege->can_browse) return true;
94 94
             else return false;
95
-        }else{
95
+        } else {
96 96
             return true;
97 97
         }
98 98
     }
99 99
 
100 100
     public function canCreate() {
101
-        if($this->privilege) {
102
-            if($this->privilege->can_create) return true;
101
+        if ($this->privilege) {
102
+            if ($this->privilege->can_create) return true;
103 103
             else return false;
104
-        }else{
104
+        } else {
105 105
             return true;
106 106
         }
107 107
     }
108 108
 
109 109
     public function canRead() {
110
-        if($this->privilege) {
111
-            if($this->privilege->can_read) return true;
110
+        if ($this->privilege) {
111
+            if ($this->privilege->can_read) return true;
112 112
             else return false;
113
-        }else{
113
+        } else {
114 114
             return true;
115 115
         }
116 116
     }
117 117
 
118 118
     public function canUpdate() {
119
-        if($this->privilege) {
120
-            if($this->privilege->can_update) return true;
119
+        if ($this->privilege) {
120
+            if ($this->privilege->can_update) return true;
121 121
             else return false;
122
-        }else{
122
+        } else {
123 123
             return true;
124 124
         }
125 125
     }
126 126
 
127 127
     public function canDelete() {
128
-        if($this->privilege) {
129
-            if($this->privilege->can_delete) return true;
128
+        if ($this->privilege) {
129
+            if ($this->privilege->can_delete) return true;
130 130
             else return false;
131
-        }else{
131
+        } else {
132 132
             return true;
133 133
         }
134 134
     }
135 135
 
136 136
     public function addURL()
137 137
     {
138
-        if($this->controller_class && method_exists($this->controller_class, 'getAdd')) {
138
+        if ($this->controller_class && method_exists($this->controller_class, 'getAdd')) {
139 139
             return action($this->controller.'@getAdd');
140
-        }else{
140
+        } else {
141 141
             return null;
142 142
         }
143 143
     }
144 144
 
145 145
     public function addSaveURL()
146 146
     {
147
-        if($this->controller_class && method_exists($this->controller_class, 'postAddSave')) {
147
+        if ($this->controller_class && method_exists($this->controller_class, 'postAddSave')) {
148 148
             return action($this->controller.'@postAddSave');
149
-        }else{
149
+        } else {
150 150
             return null;
151 151
         }
152 152
     }
153 153
 
154 154
     public function editURL($id = null)
155 155
     {
156
-        if($this->controller_class && method_exists($this->controller_class, 'getEdit')) {
157
-            return action($this->controller.'@getEdit',['id'=>$id]);
158
-        }else{
156
+        if ($this->controller_class && method_exists($this->controller_class, 'getEdit')) {
157
+            return action($this->controller.'@getEdit', ['id'=>$id]);
158
+        } else {
159 159
             return null;
160 160
         }
161 161
     }
162 162
 
163 163
     public function editSaveURL($id = null)
164 164
     {
165
-        if(method_exists($this->controller_class, 'postEditSave')) {
166
-            return action($this->controller.'@postEditSave',['id'=>$id]);
167
-        }else{
165
+        if (method_exists($this->controller_class, 'postEditSave')) {
166
+            return action($this->controller.'@postEditSave', ['id'=>$id]);
167
+        } else {
168 168
             return null;
169 169
         }
170 170
     }
171 171
 
172
-    public function detailURL($id=null)
172
+    public function detailURL($id = null)
173 173
     {
174
-        if($this->controller_class && method_exists($this->controller_class, 'getDetail')) {
175
-            return action($this->controller.'@getDetail',['id'=>$id]);
176
-        }else{
174
+        if ($this->controller_class && method_exists($this->controller_class, 'getDetail')) {
175
+            return action($this->controller.'@getDetail', ['id'=>$id]);
176
+        } else {
177 177
             return null;
178 178
         }
179 179
     }
180 180
 
181
-    public function deleteURL($id=null)
181
+    public function deleteURL($id = null)
182 182
     {
183
-        if($this->controller_class && method_exists($this->controller_class, 'getDelete')) {
184
-            return action($this->controller.'@getDelete',['id'=>$id]);
185
-        }else{
183
+        if ($this->controller_class && method_exists($this->controller_class, 'getDelete')) {
184
+            return action($this->controller.'@getDelete', ['id'=>$id]);
185
+        } else {
186 186
             return null;
187 187
         }
188 188
     }
189 189
 
190 190
     public function url($path = null)
191 191
     {
192
-        if($this->controller_class && method_exists($this->controller_class, 'getIndex')) {
193
-            return trim(action($this->controller.'@getIndex').'/'.$path,'/');
194
-        }else{
192
+        if ($this->controller_class && method_exists($this->controller_class, 'getIndex')) {
193
+            return trim(action($this->controller.'@getIndex').'/'.$path, '/');
194
+        } else {
195 195
             return null;
196 196
         }
197 197
     }
Please login to merge, or discard this patch.
src/helpers/CacheHelper.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@  discard block
 block discarded – undo
15 15
 {
16 16
     public static function putInGroup($key, $value, $group, $duration) {
17 17
         $key = md5($key);
18
-        $exist = (Cache::get($group))?:[];
19
-        $exist[ $key ] = ['value'=>$value,'duration'=>$duration];
18
+        $exist = (Cache::get($group)) ?: [];
19
+        $exist[$key] = ['value'=>$value, 'duration'=>$duration];
20 20
 
21
-        if($duration == -1) {
21
+        if ($duration == -1) {
22 22
             Cache::forever($group, $exist);
23 23
         } else {
24 24
             Cache::put($group, $exist, $duration);
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     public static function getItemInGroup($key, $group) {
29 29
         $groupdata = Cache::get($group);
30 30
         $key = md5($key);
31
-        if(isset($groupdata[$key])) {
31
+        if (isset($groupdata[$key])) {
32 32
             return $groupdata[$key]['value'];
33 33
         }
34 34
         return null;
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
         Cache::forget($group);
39 39
     }
40 40
 
41
-    public static function forgetInGroup($key,$group) {
41
+    public static function forgetInGroup($key, $group) {
42 42
         $key = md5($key);
43 43
         $data = Cache::get($group);
44 44
         $duration = null;
45
-        if(isset($data[$key])) {
45
+        if (isset($data[$key])) {
46 46
             $item = $data[$key];
47 47
             unset($data[$key]);
48 48
         }
Please login to merge, or discard this patch.