Passed
Push — master ( decd12...98156d )
by Ferry
05:10
created
src/configs/crudbooster.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
     /*
32 32
      * For security reason we have limit the upload file formats bellow
33 33
      */
34
-    'UPLOAD_FILE_EXTENSION_ALLOWED' => ['jpg','jpeg','png','gif','pdf','xls','xlsx','doc','docx','txt','zip','rar','rtf'],
34
+    'UPLOAD_FILE_EXTENSION_ALLOWED' => ['jpg', 'jpeg', 'png', 'gif', 'pdf', 'xls', 'xlsx', 'doc', 'docx', 'txt', 'zip', 'rar', 'rtf'],
35 35
 
36
-    'UPLOAD_IMAGE_EXTENSION_ALLOWED' => ['jpg','jpeg','png','gif'],
36
+    'UPLOAD_IMAGE_EXTENSION_ALLOWED' => ['jpg', 'jpeg', 'png', 'gif'],
37 37
 
38 38
     /*
39 39
      * Override Local FileSystem From Storage To Another
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      * You can define in this array what the tables you want to include in "php artisan crudbooster:data_migration"
70 70
      * The default is all cb_ prefix will be include in data migration
71 71
      */
72
-    'ADDITIONAL_DATA_MIGRATION'=>['users','migrations'],
72
+    'ADDITIONAL_DATA_MIGRATION'=>['users', 'migrations'],
73 73
 
74 74
 
75 75
     /*
Please login to merge, or discard this patch.
src/helpers/CB.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 {
21 21
 
22 22
     public function getRoleByName($roleName) {
23
-        return $this->find("cb_roles",['name'=>$roleName]);
23
+        return $this->find("cb_roles", ['name'=>$roleName]);
24 24
     }
25 25
 
26 26
     public function fcm() {
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     }
37 37
 
38 38
     public function getDeveloperUrl($path = null) {
39
-        $path = ($path)?"/".trim($path,"/"):null;
39
+        $path = ($path) ? "/".trim($path, "/") : null;
40 40
         return url("developer/".getSetting("developer_path")).$path;
41 41
     }
42 42
 
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
     }
54 54
 
55 55
     public function getAdminUrl($path = null) {
56
-        $path = ($path)?"/".trim($path,"/"):null;
56
+        $path = ($path) ? "/".trim($path, "/") : null;
57 57
         return url(cbConfig("ADMIN_PATH")).$path;
58 58
     }
59 59
 
60 60
     public function getAppName() {
61
-        return env("APP_NAME","CRUDBOOSTER");
61
+        return env("APP_NAME", "CRUDBOOSTER");
62 62
     }
63 63
 
64 64
     /**
@@ -72,16 +72,16 @@  discard block
 block discarded – undo
72 72
      */
73 73
     private function uploadFileProcess($filename, $extension, $file, $encrypt = true, $resize_width = null, $resize_height = null)
74 74
     {
75
-        if(in_array($extension,cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) {
75
+        if (in_array($extension, cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) {
76 76
             $file_path = cbConfig("UPLOAD_PATH_FORMAT");
77
-            $file_path = str_replace("{Y}",date('Y'), $file_path);
77
+            $file_path = str_replace("{Y}", date('Y'), $file_path);
78 78
             $file_path = str_replace("{m}", date('m'), $file_path);
79 79
             $file_path = str_replace("{d}", date("d"), $file_path);
80 80
 
81 81
             //Create Directory Base On Template
82 82
             Storage::makeDirectory($file_path);
83
-            Storage::put($file_path."/index.html"," ","public");
84
-            Storage::put($file_path."/.gitignore","!.gitignore","public");
83
+            Storage::put($file_path."/index.html", " ", "public");
84
+            Storage::put($file_path."/.gitignore", "!.gitignore", "public");
85 85
 
86 86
             if ($encrypt == true) {
87 87
                 $filename = md5(strRandom(5)).'.'.$extension;
@@ -89,17 +89,17 @@  discard block
 block discarded – undo
89 89
                 $filename = slug($filename, '_').'.'.$extension;
90 90
             }
91 91
 
92
-            if($resize_width || $resize_height) {
92
+            if ($resize_width || $resize_height) {
93 93
                 $this->resizeImage($file, $file_path.'/'.$filename, $resize_width, $resize_height);
94 94
                 return $file_path.'/'.$filename;
95
-            }else{
95
+            } else {
96 96
                 if (Storage::put($file_path.'/'.$filename, $file, 'public')) {
97 97
                     return $file_path.'/'.$filename;
98 98
                 } else {
99 99
                     throw new \Exception("Something went wrong, file can't upload!");
100 100
                 }
101 101
             }
102
-        }else{
102
+        } else {
103 103
             throw new \Exception("The file format is not allowed!");
104 104
         }
105 105
     }
@@ -115,16 +115,16 @@  discard block
 block discarded – undo
115 115
     {
116 116
         $fileData = base64_decode($base64_value);
117 117
         $mime_type = finfo_buffer(finfo_open(), $fileData, FILEINFO_MIME_TYPE);
118
-        if($mime_type) {
119
-            if($mime_type = explode('/', $mime_type)) {
118
+        if ($mime_type) {
119
+            if ($mime_type = explode('/', $mime_type)) {
120 120
                 $ext = $mime_type[1];
121
-                if($filename && $ext) {
121
+                if ($filename && $ext) {
122 122
                     return $this->uploadFileProcess($filename, $ext, $fileData, $encrypt, $resize_width, $resize_height);
123 123
                 }
124
-            }else {
124
+            } else {
125 125
                 throw new \Exception("Mime type not found");
126 126
             }
127
-        }else{
127
+        } else {
128 128
             throw new \Exception("Mime type not found");
129 129
         }
130 130
     }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
             $filename = $file->getClientOriginalName();
145 145
             $ext = strtolower($file->getClientOriginalExtension());
146 146
 
147
-            if($filename && $ext) {
147
+            if ($filename && $ext) {
148 148
                 return $this->uploadFileProcess($filename, $ext, $file, $encrypt, $resize_width, $resize_height);
149 149
             }
150 150
 
@@ -179,29 +179,29 @@  discard block
 block discarded – undo
179 179
             if ($resize_width && $resize_height) {
180 180
                 $img->fit($resize_width, $resize_height);
181 181
 
182
-            } elseif ($resize_width && ! $resize_height) {
182
+            } elseif ($resize_width && !$resize_height) {
183 183
 
184
-                $img->resize($resize_width, null, function ($constraint) {
184
+                $img->resize($resize_width, null, function($constraint) {
185 185
                     $constraint->aspectRatio();
186 186
                 });
187 187
 
188
-            } elseif (! $resize_width && $resize_height) {
188
+            } elseif (!$resize_width && $resize_height) {
189 189
 
190
-                $img->resize(null, $resize_height, function ($constraint) {
190
+                $img->resize(null, $resize_height, function($constraint) {
191 191
                     $constraint->aspectRatio();
192 192
                 });
193 193
 
194 194
             } else {
195 195
 
196 196
                 if ($img->width() > cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES")) {
197
-                    $img->resize(cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES"), null, function ($constraint) {
197
+                    $img->resize(cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES"), null, function($constraint) {
198 198
                         $constraint->aspectRatio();
199 199
                     });
200 200
                 }
201 201
             }
202 202
 
203 203
             Storage::put($fullFilePath, $img, 'public');
204
-        }else{
204
+        } else {
205 205
             throw new \Exception("The file format is not allowed!");
206 206
         }
207 207
     }
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
         $validator = Validator::make($input_arr, $rules, $messages);
315 315
         if ($validator->fails()) {
316 316
             $message = $validator->errors()->all();
317
-            throw new CBValidationException(implode("; ",$message));
317
+            throw new CBValidationException(implode("; ", $message));
318 318
         }
319 319
     }
320 320
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
     public function findPrimaryKey($table)
327 327
     {
328 328
         $pk = DB::getDoctrineSchemaManager()->listTableDetails($table)->getPrimaryKey();
329
-        if(!$pk) {
329
+        if (!$pk) {
330 330
             return null;
331 331
         }
332 332
         return $pk->getColumns()[0];
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
             $string_parameters_array = explode('&', $string_parameters);
376 376
             foreach ($string_parameters_array as $s) {
377 377
                 $part = explode('=', $s);
378
-                if(isset($part[0]) && isset($part[1])) {
378
+                if (isset($part[0]) && isset($part[1])) {
379 379
                     $name = htmlspecialchars(urldecode($part[0]));
380 380
                     $name = strip_tags($name);
381 381
                     $value = htmlspecialchars(urldecode($part[1]));
@@ -392,16 +392,16 @@  discard block
 block discarded – undo
392 392
 
393 393
 
394 394
     public function routeGet($prefix, $controller) {
395
-        $alias = str_replace("@"," ", $controller);
395
+        $alias = str_replace("@", " ", $controller);
396 396
         $alias = ucwords($alias);
397
-        $alias = str_replace(" ","",$alias);
397
+        $alias = str_replace(" ", "", $alias);
398 398
         Route::get($prefix, ['uses' => $controller, 'as' => $alias]);
399 399
     }
400 400
 
401 401
     public function routePost($prefix, $controller) {
402
-        $alias = str_replace("@"," ", $controller);
402
+        $alias = str_replace("@", " ", $controller);
403 403
         $alias = ucwords($alias);
404
-        $alias = str_replace(" ","",$alias);
404
+        $alias = str_replace(" ", "", $alias);
405 405
         Route::post($prefix, ['uses' => $controller, 'as' => $alias]);
406 406
     }
407 407
 
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 
427 427
         $prefix = trim($prefix, '/').'/';
428 428
 
429
-        if(substr($controller,0,1) != "\\") {
429
+        if (substr($controller, 0, 1) != "\\") {
430 430
             $controller = "\App\Http\Controllers\\".$controller;
431 431
         }
432 432
 
Please login to merge, or discard this patch.
src/helpers/Helper.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 |
10 10
 */
11 11
 
12
-if(!function_exists("cbLang")) {
12
+if (!function_exists("cbLang")) {
13 13
     /**
14 14
      * @param string $key
15 15
      * @param array $replace
@@ -21,17 +21,17 @@  discard block
 block discarded – undo
21 21
     }
22 22
 }
23 23
 
24
-if(!function_exists('rglob')) {
24
+if (!function_exists('rglob')) {
25 25
     function rglob($pattern, $flags = 0) {
26 26
         $files = glob($pattern, $flags);
27
-        foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
27
+        foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
28 28
             $files = array_merge($files, rglob($dir.'/'.basename($pattern), $flags));
29 29
         }
30 30
         return $files;
31 31
     }
32 32
 }
33 33
 
34
-if(!function_exists('convertPHPToMomentFormat')) {
34
+if (!function_exists('convertPHPToMomentFormat')) {
35 35
     function convertPHPToMomentFormat($format)
36 36
     {
37 37
         $replacements = [
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
     }
79 79
 }
80 80
 
81
-if(!function_exists('slug')) {
81
+if (!function_exists('slug')) {
82 82
     function slug($string, $separator = '-') {
83 83
         return \Illuminate\Support\Str::slug($string, $separator);
84 84
     }
85 85
 }
86 86
 
87
-if(!function_exists('columnSingleton')) {
87
+if (!function_exists('columnSingleton')) {
88 88
     /**
89 89
      * @return \crocodicstudio\crudbooster\controllers\scaffolding\singletons\ColumnSingleton
90 90
      */
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     }
94 94
 }
95 95
 
96
-if(!function_exists('cbHook'))
96
+if (!function_exists('cbHook'))
97 97
 {
98 98
     /**
99 99
      * @return crocodicstudio\crudbooster\hooks\CBHook
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     }
106 106
 }
107 107
 
108
-if(!function_exists('getTypeHook'))
108
+if (!function_exists('getTypeHook'))
109 109
 {
110 110
     /**
111 111
      * @param string $type
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     }
119 119
 }
120 120
 
121
-if(!function_exists('getPrimaryKey'))
121
+if (!function_exists('getPrimaryKey'))
122 122
 {
123 123
     function getPrimaryKey($table_name)
124 124
     {
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     }
127 127
 }
128 128
 
129
-if(!function_exists('cb'))
129
+if (!function_exists('cb'))
130 130
 {
131 131
     function cb()
132 132
     {
@@ -134,25 +134,25 @@  discard block
 block discarded – undo
134 134
     }
135 135
 }
136 136
 
137
-if(!function_exists('cbAsset')) {
137
+if (!function_exists('cbAsset')) {
138 138
     function cbAsset($path) {
139 139
         return asset("cb_asset/".$path);
140 140
     }
141 141
 }
142 142
 
143
-if(!function_exists("cbConfig")) {
143
+if (!function_exists("cbConfig")) {
144 144
     function cbConfig($name) {
145 145
         return config("crudbooster.".$name);
146 146
     }
147 147
 }
148 148
 
149
-if(!function_exists("strRandom")) {
149
+if (!function_exists("strRandom")) {
150 150
     function strRandom($length = 5) {
151 151
         return \Illuminate\Support\Str::random($length);
152 152
     }
153 153
 }
154 154
 
155
-if(!function_exists('module')) {
155
+if (!function_exists('module')) {
156 156
     function module()
157 157
     {
158 158
         $module = new \crocodicstudio\crudbooster\helpers\Module();
@@ -160,43 +160,43 @@  discard block
 block discarded – undo
160 160
     }
161 161
 }
162 162
 
163
-if(!function_exists('getAdminLoginURL')) {
163
+if (!function_exists('getAdminLoginURL')) {
164 164
     function getAdminLoginURL()
165 165
     {
166 166
         return url(config('crudbooster.ADMIN_LOGIN_PATH'));
167 167
     }
168 168
 }
169 169
 
170
-if(!function_exists('dummyPhoto')) {
170
+if (!function_exists('dummyPhoto')) {
171 171
     function dummyPhoto()
172 172
     {
173 173
         return cbConfig("DUMMY_PHOTO");
174 174
     }
175 175
 }
176 176
 
177
-if(!function_exists('assetThumbnail')) {
177
+if (!function_exists('assetThumbnail')) {
178 178
 	function assetThumbnail($path) {
179
-		$path = str_replace('uploads/','uploads_thumbnail/',$path);
179
+		$path = str_replace('uploads/', 'uploads_thumbnail/', $path);
180 180
 		return asset($path);
181 181
 	}
182 182
 }
183 183
 
184
-if(!function_exists('assetResize')) {
185
-	function assetResize($path,$width,$height=null,$quality=70) {
184
+if (!function_exists('assetResize')) {
185
+	function assetResize($path, $width, $height = null, $quality = 70) {
186 186
 		$basename = basename($path);
187 187
 	    $pathWithoutName = str_replace($basename, '', $path);
188 188
 	    $newLocation = $pathWithoutName.'/w_'.$width.'_h_'.$height.'_'.$basename;
189
-	    if(Storage::exists($newLocation)) {
189
+	    if (Storage::exists($newLocation)) {
190 190
 	        return asset($newLocation);
191
-	    }else{
192
-	        $img = Image::make(storage_path($path))->fit($width,$height);
193
-	        $img->save(storage_path($newLocation),$quality);
191
+	    } else {
192
+	        $img = Image::make(storage_path($path))->fit($width, $height);
193
+	        $img->save(storage_path($newLocation), $quality);
194 194
 	        return asset($newLocation);
195 195
 	    }
196 196
 	}
197 197
 }
198 198
 
199
-if(!function_exists('extract_unit')) {	
199
+if (!function_exists('extract_unit')) {	
200 200
 	/*
201 201
 	Credits: Bit Repository
202 202
 	URL: http://www.bitrepository.com/extract-content-between-two-delimiters-with-php.html
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 }
215 215
 
216 216
 
217
-if(!function_exists('now')) {
217
+if (!function_exists('now')) {
218 218
 	function now() {		
219 219
 		return date('Y-m-d H:i:s');
220 220
 	}
@@ -228,14 +228,14 @@  discard block
 block discarded – undo
228 228
 |
229 229
 */
230 230
 
231
-if(!function_exists('putSetting')) {
231
+if (!function_exists('putSetting')) {
232 232
     function putSetting($key, $value)
233 233
     {
234
-        if(file_exists(storage_path('.cbconfig'))) {
234
+        if (file_exists(storage_path('.cbconfig'))) {
235 235
             $settings = file_get_contents(storage_path('.cbconfig'));
236 236
             $settings = decrypt($settings);
237 237
             $settings = unserialize($settings);
238
-        }else{
238
+        } else {
239 239
             $settings = [];
240 240
         }
241 241
 
@@ -249,31 +249,31 @@  discard block
 block discarded – undo
249 249
     }
250 250
 }
251 251
 
252
-if(!function_exists('getSetting')) {
252
+if (!function_exists('getSetting')) {
253 253
     function getSetting($key, $default = null)
254 254
     {
255
-        if($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) {
255
+        if ($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) {
256 256
             return $cache;
257 257
         }
258 258
 
259
-        if(file_exists(storage_path('.cbconfig'))) {
259
+        if (file_exists(storage_path('.cbconfig'))) {
260 260
             $settings = file_get_contents(storage_path('.cbconfig'));
261 261
             $settings = decrypt($settings);
262 262
             $settings = unserialize($settings);
263
-        }else{
263
+        } else {
264 264
             $settings = [];
265 265
         }
266 266
 
267
-        if(isset($settings[$key])) {
267
+        if (isset($settings[$key])) {
268 268
             \Illuminate\Support\Facades\Cache::put("setting_".$key, $settings[$key], 180);
269
-            return $settings[$key]?:$default;
270
-        }else{
269
+            return $settings[$key] ?: $default;
270
+        } else {
271 271
             return $default;
272 272
         }
273 273
     }
274 274
 }
275 275
 
276
-if(!function_exists('timeAgo')) {
276
+if (!function_exists('timeAgo')) {
277 277
     function timeAgo($datetime_to, $datetime_from = null, $full = false)
278 278
     {
279 279
         $datetime_from = ($datetime_from) ?: date('Y-m-d H:i:s');
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
             }
305 305
         }
306 306
 
307
-        if (! $full) {
307
+        if (!$full) {
308 308
             $string = array_slice($string, 0, 1);
309 309
         }
310 310
 
@@ -312,22 +312,22 @@  discard block
 block discarded – undo
312 312
     }
313 313
 }
314 314
 
315
-if(!function_exists("array_map_r")) {
316
-    function array_map_r( $func, $arr )
315
+if (!function_exists("array_map_r")) {
316
+    function array_map_r($func, $arr)
317 317
     {
318 318
         $newArr = array();
319 319
 
320
-        foreach( $arr as $key => $value )
320
+        foreach ($arr as $key => $value)
321 321
         {
322 322
             $key = $func($key);
323
-            $newArr[ $key ] = ( is_array( $value ) ? array_map_r( $func, $value ) : ( is_array($func) ? call_user_func_array($func, $value) : $func( $value ) ) );
323
+            $newArr[$key] = (is_array($value) ? array_map_r($func, $value) : (is_array($func) ? call_user_func_array($func, $value) : $func($value)));
324 324
         }
325 325
 
326 326
         return $newArr;
327 327
     }
328 328
 }
329 329
 
330
-if(!function_exists("sanitizeXSS"))
330
+if (!function_exists("sanitizeXSS"))
331 331
 {
332 332
     function sanitizeXSS($value)
333 333
     {
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
     }
340 340
 }
341 341
 
342
-if(!function_exists("requestAll")) {
342
+if (!function_exists("requestAll")) {
343 343
     function requestAll() {
344 344
         $all = array_map_r("sanitizeXSS", request()->all());
345 345
         return $all;
@@ -348,22 +348,22 @@  discard block
 block discarded – undo
348 348
 
349 349
 
350 350
 
351
-if(!function_exists('getURLFormat')) {
351
+if (!function_exists('getURLFormat')) {
352 352
     function getURLFormat($name) {
353 353
         $url = request($name);
354
-        if(filter_var($url, FILTER_VALIDATE_URL)) {
354
+        if (filter_var($url, FILTER_VALIDATE_URL)) {
355 355
             return $url;
356
-        }else{
356
+        } else {
357 357
             return request()->url();
358 358
         }
359 359
     }
360 360
 }
361 361
 
362
-if(!function_exists('g')) {
362
+if (!function_exists('g')) {
363 363
     function g($name, $safe = true) {
364
-        if($safe == true) {
364
+        if ($safe == true) {
365 365
             $response = request($name);
366
-            if(is_string($response)) {
366
+            if (is_string($response)) {
367 367
                 $response = sanitizeXSS($response);
368 368
             }elseif (is_array($response)) {
369 369
                 array_walk_recursive($response, function(&$response) {
@@ -372,25 +372,25 @@  discard block
 block discarded – undo
372 372
             }
373 373
 
374 374
             return $response;
375
-        }else{
375
+        } else {
376 376
             return Request::get($name);
377 377
         }
378 378
     }
379 379
 }
380 380
 
381
-if(!function_exists('min_var_export')) {
381
+if (!function_exists('min_var_export')) {
382 382
     function min_var_export($input) {
383
-        if(is_array($input)) {
383
+        if (is_array($input)) {
384 384
             $buffer = [];
385
-            foreach($input as $key => $value)
385
+            foreach ($input as $key => $value)
386 386
                 $buffer[] = var_export($key, true)."=>".min_var_export($value);
387
-            return "[".implode(",",$buffer)."]";
387
+            return "[".implode(",", $buffer)."]";
388 388
         } else
389 389
             return var_export($input, true);
390 390
     }
391 391
 }
392 392
 
393
-if(!function_exists('rrmdir')) {
393
+if (!function_exists('rrmdir')) {
394 394
 	/*
395 395
 	* http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir
396 396
 	*/
Please login to merge, or discard this patch.
src/controllers/CBController.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
 
28 28
     public function __call($method, $parameters)
29 29
     {
30
-        if($method == "getData") {
30
+        if ($method == "getData") {
31 31
             $key = $parameters[0];
32
-            if(isset($this->data[$key])) {
32
+            if (isset($this->data[$key])) {
33 33
                 return $this->data[$key];
34
-            }else{
34
+            } else {
35 35
                 return null;
36 36
             }
37
-        }else{
37
+        } else {
38 38
             return null;
39 39
         }
40 40
     }
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 
49 49
         $query->addSelect($this->data['table'].'.'.cb()->pk($this->data['table']).' as primary_key');
50 50
 
51
-        $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true;
52
-        if($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) {
51
+        $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true;
52
+        if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) {
53 53
             $query->whereNull($this->data['table'].'.deleted_at');
54 54
         }
55 55
         
56
-        if(isset($joins)) {
57
-            foreach($joins as $join)
56
+        if (isset($joins)) {
57
+            foreach ($joins as $join)
58 58
             {
59 59
                 $query->join($join['target_table'],
60 60
                         $join['target_table_primary'],
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
             }
65 65
         }
66 66
 
67
-        foreach($columns as $column) {
67
+        foreach ($columns as $column) {
68 68
             /** @var ColumnModel $column */
69
-            if($column->getType() != "custom") {
70
-                if(strpos($column->getField(),".") === false) {
71
-                    if(Schema::hasColumn($this->data['table'], $column->getField())) {
69
+            if ($column->getType() != "custom") {
70
+                if (strpos($column->getField(), ".") === false) {
71
+                    if (Schema::hasColumn($this->data['table'], $column->getField())) {
72 72
                         $query->addSelect($this->data['table'].'.'.$column->getField());
73 73
                     }
74
-                }else{
74
+                } else {
75 75
                     $query->addSelect($column->getField());
76 76
                 }
77 77
             }
@@ -79,20 +79,20 @@  discard block
 block discarded – undo
79 79
             $query = getTypeHook($column->getType())->query($query, $column);
80 80
         }
81 81
 
82
-        if(request()->has('q'))
82
+        if (request()->has('q'))
83 83
         {
84
-            if(isset($this->data['hook_search_query'])) {
84
+            if (isset($this->data['hook_search_query'])) {
85 85
                 $query = call_user_func($this->data['hook_search_query'], $query);
86
-            }else{
87
-                $query->where(function ($where) use ($columns) {
86
+            } else {
87
+                $query->where(function($where) use ($columns) {
88 88
                     /**
89 89
                      * @var $where Builder
90 90
                      */
91
-                    foreach($columns as $column)
91
+                    foreach ($columns as $column)
92 92
                     {
93
-                        if(strpos($column->getField(),".") === false) {
93
+                        if (strpos($column->getField(), ".") === false) {
94 94
                             $field = $this->data['table'].'.'.$column->getField();
95
-                        }else{
95
+                        } else {
96 96
                             $field = $column->getField();
97 97
                         }
98 98
                         $where->orWhere($field, 'like', '%'.request('q').'%');
@@ -101,17 +101,17 @@  discard block
 block discarded – undo
101 101
             }
102 102
         }
103 103
 
104
-        if(isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) {
104
+        if (isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) {
105 105
             $query = call_user_func($this->data['hook_index_query'], $query);
106 106
         }
107 107
 
108 108
 
109
-        if(request()->has(['order_by','order_sort']))
109
+        if (request()->has(['order_by', 'order_sort']))
110 110
         {
111
-            if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) {
111
+            if (in_array(request('order_by'), columnSingleton()->getColumnNameOnly())) {
112 112
                 $query->orderBy(request('order_by'), request('order_sort'));
113 113
             }
114
-        }else{
114
+        } else {
115 115
             $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc");
116 116
         }
117 117
 
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
 
121 121
     public function getIndex()
122 122
     {
123
-        if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
123
+        if (!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area"));
124 124
 
125 125
         $query = $this->repository();
126
-        $result = $query->paginate( request("limit")?:cbConfig("LIMIT_TABLE_DATA") );
126
+        $result = $query->paginate(request("limit") ?: cbConfig("LIMIT_TABLE_DATA"));
127 127
         $data['result'] = $result;
128 128
 
129 129
         return view("crudbooster::module.index.index", array_merge($data, $this->data));
@@ -135,29 +135,29 @@  discard block
 block discarded – undo
135 135
      */
136 136
     private function validation()
137 137
     {
138
-        if(isset($this->data['validation'])) {
138
+        if (isset($this->data['validation'])) {
139 139
             $validator = Validator::make(request()->all(), @$this->data['validation'], @$this->data['validation_messages']);
140 140
             if ($validator->fails()) {
141 141
                 $message = $validator->messages();
142 142
                 $message_all = $message->all();
143
-                throw new CBValidationException(implode(', ',$message_all));
143
+                throw new CBValidationException(implode(', ', $message_all));
144 144
             }
145 145
         }
146 146
     }
147 147
 
148 148
     public function getAdd()
149 149
     {
150
-        if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
150
+        if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area"));
151 151
 
152 152
         $data = [];
153 153
         $data['page_title'] = $this->data['page_title'].' : '.cbLang('add');
154 154
         $data['action_url'] = module()->addSaveURL();
155
-        return view('crudbooster::module.form.form',array_merge($data, $this->data));
155
+        return view('crudbooster::module.form.form', array_merge($data, $this->data));
156 156
     }
157 157
 
158 158
     public function postAddSave()
159 159
     {
160
-        if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
160
+        if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area"));
161 161
 
162 162
         try {
163 163
             $this->validation();
@@ -165,35 +165,35 @@  discard block
 block discarded – undo
165 165
             $data = columnSingleton()->getAssignmentData();
166 166
 
167 167
             //Clear data from Primary Key
168
-            unset($data[ cb()->pk($this->data['table']) ]);
168
+            unset($data[cb()->pk($this->data['table'])]);
169 169
 
170
-            if(Schema::hasColumn($this->data['table'], 'created_at')) {
170
+            if (Schema::hasColumn($this->data['table'], 'created_at')) {
171 171
                 $data['created_at'] = date('Y-m-d H:i:s');
172 172
             }
173 173
 
174
-            if(Schema::hasColumn($this->data['table'], 'updated_at')) {
174
+            if (Schema::hasColumn($this->data['table'], 'updated_at')) {
175 175
                 $data['updated_at'] = date('Y-m-d H:i:s');
176 176
             }
177 177
 
178
-            if(isset($this->data['hook_before_insert']) && is_callable($this->data['hook_before_insert'])) {
178
+            if (isset($this->data['hook_before_insert']) && is_callable($this->data['hook_before_insert'])) {
179 179
                 $data = call_user_func($this->data['hook_before_insert'], $data);
180 180
             }
181 181
 
182 182
             $id = DB::table($this->data['table'])->insertGetId($data);
183 183
 
184
-            if(isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) {
184
+            if (isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) {
185 185
                 call_user_func($this->data['hook_after_insert'], $id);
186 186
             }
187 187
 
188 188
         } catch (CBValidationException $e) {
189 189
             Log::debug($e);
190
-            return cb()->redirectBack($e->getMessage(),'info');
190
+            return cb()->redirectBack($e->getMessage(), 'info');
191 191
         } catch (\Exception $e) {
192 192
             Log::error($e);
193
-            return cb()->redirectBack(cbLang("something_went_wrong"),'warning');
193
+            return cb()->redirectBack(cbLang("something_went_wrong"), 'warning');
194 194
         }
195 195
 
196
-        if (Str::contains(request("submit"),cbLang("more"))) {
196
+        if (Str::contains(request("submit"), cbLang("more"))) {
197 197
             return cb()->redirect(module()->addURL(), cbLang("the_data_has_been_added"), 'success');
198 198
         } else {
199 199
             return cb()->redirect(module()->url(), cbLang("the_data_has_been_added"), 'success');
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 
203 203
     public function getEdit($id)
204 204
     {
205
-        if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
205
+        if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area"));
206 206
 
207 207
         $data = [];
208 208
         $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first();
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 
214 214
     public function postEditSave($id)
215 215
     {
216
-        if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
216
+        if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area"));
217 217
 
218 218
         try {
219 219
             $this->validation();
@@ -221,51 +221,51 @@  discard block
 block discarded – undo
221 221
             $data = columnSingleton()->getAssignmentData();
222 222
 
223 223
             // Make sure the Primary Key is not included
224
-            unset($data[ cb()->pk($this->data['table']) ]);
224
+            unset($data[cb()->pk($this->data['table'])]);
225 225
 
226
-            if(Schema::hasColumn($this->data['table'], 'updated_at')) {
226
+            if (Schema::hasColumn($this->data['table'], 'updated_at')) {
227 227
                 $data['updated_at'] = date('Y-m-d H:i:s');
228 228
             }
229 229
 
230 230
             unset($data['created_at']);
231 231
 
232
-            if(isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) {
232
+            if (isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) {
233 233
                 $data = call_user_func($this->data['hook_before_update'], $id, $data);
234 234
             }
235 235
 
236 236
             cb()->update($this->data['table'], $id, $data);
237 237
 
238
-            if(isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) {
238
+            if (isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) {
239 239
                 call_user_func($this->data['hook_after_update'], $id);
240 240
             }
241 241
 
242 242
         } catch (CBValidationException $e) {
243 243
             Log::debug($e);
244
-            return cb()->redirectBack($e->getMessage(),'info');
244
+            return cb()->redirectBack($e->getMessage(), 'info');
245 245
         } catch (\Exception $e) {
246 246
             Log::error($e);
247
-            return cb()->redirectBack(cbLang("something_went_wrong"),'warning');
247
+            return cb()->redirectBack(cbLang("something_went_wrong"), 'warning');
248 248
         }
249 249
 
250 250
 
251 251
         if (Str::contains(request("submit"), cbLang("more"))) {
252
-            return cb()->redirectBack( cbLang("the_data_has_been_updated"), 'success');
252
+            return cb()->redirectBack(cbLang("the_data_has_been_updated"), 'success');
253 253
         } else {
254
-            return cb()->redirect(module()->url(),  cbLang("the_data_has_been_updated"), 'success');
254
+            return cb()->redirect(module()->url(), cbLang("the_data_has_been_updated"), 'success');
255 255
         }
256 256
     }
257 257
 
258 258
     public function getDelete($id)
259 259
     {
260
-        if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
260
+        if (!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area"));
261 261
 
262
-        if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) {
262
+        if (isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) {
263 263
             call_user_func($this->data['hook_before_delete'], $id);
264 264
         }
265 265
 
266
-        $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true;
266
+        $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true;
267 267
 
268
-        if ($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) {
268
+        if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) {
269 269
             DB::table($this->data['table'])
270 270
                 ->where(getPrimaryKey($this->data['table']), $id)
271 271
                 ->update(['deleted_at' => date('Y-m-d H:i:s')]);
@@ -275,16 +275,16 @@  discard block
 block discarded – undo
275 275
                 ->delete();
276 276
         }
277 277
 
278
-        if(isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) {
278
+        if (isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) {
279 279
             call_user_func($this->data['hook_after_delete'], $id);
280 280
         }
281 281
 
282
-        return cb()->redirectBack( cbLang("the_data_has_been_deleted"), 'success');
282
+        return cb()->redirectBack(cbLang("the_data_has_been_deleted"), 'success');
283 283
     }
284 284
 
285 285
     public function getDetail($id)
286 286
     {
287
-        if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
287
+        if (!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area"));
288 288
 
289 289
         $data = [];
290 290
         $data['row'] = $this->repository()->where($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), $id)->first();
Please login to merge, or discard this patch.
src/controllers/AdminAuthController.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
     public function getLogin()
10 10
     {
11
-        if(!auth()->guest()) return redirect(cb()->getAdminUrl());
11
+        if (!auth()->guest()) return redirect(cb()->getAdminUrl());
12 12
 
13 13
         cbHook()->hookGetLogin();
14 14
 
@@ -17,20 +17,20 @@  discard block
 block discarded – undo
17 17
 
18 18
     public function postLogin()
19 19
     {
20
-        try{
20
+        try {
21 21
             cb()->validation([
22 22
                 'email'=>'required|email',
23 23
                 'password'=>'required'
24 24
             ]);
25
-            $credential = request()->only(['email','password']);
25
+            $credential = request()->only(['email', 'password']);
26 26
             if (auth()->attempt($credential)) {
27 27
                 cbHook()->hookPostLogin();
28 28
                 return redirect(cb()->getAdminUrl());
29 29
             } else {
30
-                return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'),'message_type'=>'warning']);
30
+                return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'), 'message_type'=>'warning']);
31 31
             }
32
-        }catch (CBValidationException $e) {
33
-            return cb()->redirect(cb()->getAdminUrl("login"),$e->getMessage(),'warning');
32
+        } catch (CBValidationException $e) {
33
+            return cb()->redirect(cb()->getAdminUrl("login"), $e->getMessage(), 'warning');
34 34
         }
35 35
     }
36 36
 
@@ -45,25 +45,25 @@  discard block
 block discarded – undo
45 45
     }
46 46
 
47 47
     public function postLoginDeveloper() {
48
-        try{
48
+        try {
49 49
             cb()->validation([
50 50
                 'username'=>'required',
51 51
                 'password'=>'required'
52 52
             ]);
53 53
 
54
-            if(request('username') == getSetting('developer_username')
54
+            if (request('username') == getSetting('developer_username')
55 55
                 && request('password') == getSetting("developer_password")) {
56 56
 
57 57
                 session(['developer'=>getSetting('developer_username')]);
58 58
 
59 59
                 return redirect(cb()->getDeveloperUrl());
60 60
 
61
-            }else{
62
-                return cb()->redirectBack( cbLang("password_and_username_is_wrong"));
61
+            } else {
62
+                return cb()->redirectBack(cbLang("password_and_username_is_wrong"));
63 63
             }
64 64
 
65
-        }catch (CBValidationException $e) {
66
-            return cb()->redirect(cb()->getLoginUrl(),$e->getMessage(),'warning');
65
+        } catch (CBValidationException $e) {
66
+            return cb()->redirect(cb()->getLoginUrl(), $e->getMessage(), 'warning');
67 67
         }
68 68
     }
69 69
 
Please login to merge, or discard this patch.
src/middlewares/CBDeveloper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@
 block discarded – undo
18 18
     public function handle($request, Closure $next)
19 19
     {
20 20
 
21
-        if(session()->get("developer") != getSetting('developer_username')) {
22
-            return cb()->redirect(cb()->getDeveloperUrl("login"),"Please login for first");
21
+        if (session()->get("developer") != getSetting('developer_username')) {
22
+            return cb()->redirect(cb()->getDeveloperUrl("login"), "Please login for first");
23 23
         }
24 24
 
25 25
         return $next($request);
Please login to merge, or discard this patch.
src/CRUDBoosterServiceProvider.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
25 25
         // Register views
26 26
         $this->loadViewsFrom(__DIR__.'/views', 'crudbooster');
27 27
         $this->loadViewsFrom(__DIR__.'/types', 'types');
28
-        $this->loadTranslationsFrom(__DIR__."/localization","cb");
28
+        $this->loadTranslationsFrom(__DIR__."/localization", "cb");
29 29
 
30 30
         // Publish the files
31
-        $this->publishes([__DIR__.'/configs/crudbooster.php' => config_path('crudbooster.php')],'cb_config');
32
-        $this->publishes([__DIR__.'/database' => base_path('database')],'cb_migration');
33
-        $this->publishes([__DIR__.'/templates/CBHook.stub'=> app_path('Http/CBHook.php')],'cb_hook');
34
-        $this->publishes([__DIR__ . '/assets' =>public_path('cb_asset')],'cb_asset');
31
+        $this->publishes([__DIR__.'/configs/crudbooster.php' => config_path('crudbooster.php')], 'cb_config');
32
+        $this->publishes([__DIR__.'/database' => base_path('database')], 'cb_migration');
33
+        $this->publishes([__DIR__.'/templates/CBHook.stub'=> app_path('Http/CBHook.php')], 'cb_hook');
34
+        $this->publishes([__DIR__.'/assets' =>public_path('cb_asset')], 'cb_asset');
35 35
 
36 36
         // Override Local FileSystem
37 37
         Config::set("filesystems.disks.local.root", cbConfig("LOCAL_FILESYSTEM_PATH", public_path("storage")));
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
         require __DIR__.'/helpers/Helper.php';
53 53
 
54 54
         // Singletons
55
-        $this->app->singleton('crudbooster', function ()
55
+        $this->app->singleton('crudbooster', function()
56 56
         {
57 57
             return true;
58 58
         });
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         }
71 71
 
72 72
         // Merging configuration
73
-        $this->mergeConfigFrom(__DIR__.'/configs/crudbooster.php','crudbooster');
73
+        $this->mergeConfigFrom(__DIR__.'/configs/crudbooster.php', 'crudbooster');
74 74
 
75 75
         // Register additional library
76 76
         $this->app->register('Intervention\Image\ImageServiceProvider');
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
     private function registerTypeRoutes() {
83 83
         $routes = rglob(__DIR__.DIRECTORY_SEPARATOR."types".DIRECTORY_SEPARATOR."Route.php");
84
-        foreach($routes as $route) {
84
+        foreach ($routes as $route) {
85 85
             require $route;
86 86
         }
87 87
     }
Please login to merge, or discard this patch.
src/commands/DeveloperCommandService.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,15 +25,15 @@
 block discarded – undo
25 25
     {
26 26
 
27 27
         try {
28
-            if(@$this->command->option("password") == "AUTO" || !@$this->command->option("password")) {
28
+            if (@$this->command->option("password") == "AUTO" || !@$this->command->option("password")) {
29 29
                 $password = Str::random(16);
30
-            }else{
30
+            } else {
31 31
                 $password = $this->command->option("password");
32 32
             }
33 33
 
34
-            if(@$this->command->option("username") == "AUTO" || !@$this->command->option("username")) {
34
+            if (@$this->command->option("username") == "AUTO" || !@$this->command->option("username")) {
35 35
                 $username = Str::random(5);
36
-            }else{
36
+            } else {
37 37
                 $username = $this->command->option("username");
38 38
             }
39 39
         } catch (\Exception $e) {
Please login to merge, or discard this patch.