Passed
Push — master ( e0b6af...ab23d3 )
by Ferry
11:54
created
src/controllers/AdminAuthController.php 2 patches
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,7 +33,9 @@  discard block
 block discarded – undo
33 33
 
34 34
     public function getLogin()
35 35
     {
36
-        if(!auth()->guest()) return redirect(cb()->getAdminUrl());
36
+        if(!auth()->guest()) {
37
+            return redirect(cb()->getAdminUrl());
38
+        }
37 39
 
38 40
         cbHook()->hookGetLogin();
39 41
 
@@ -43,7 +45,9 @@  discard block
 block discarded – undo
43 45
     public function postLogin()
44 46
     {
45 47
         try{
46
-            if($this->isSuspendedLogin()) throw new CBValidationException(cbLang("you_have_been_suspended"));
48
+            if($this->isSuspendedLogin()) {
49
+                throw new CBValidationException(cbLang("you_have_been_suspended"));
50
+            }
47 51
 
48 52
             cb()->validation([
49 53
                 'email'=>'required|email',
@@ -58,7 +62,7 @@  discard block
 block discarded – undo
58 62
                 $this->incrementFailedLogin();
59 63
                 return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'),'message_type'=>'warning']);
60 64
             }
61
-        }catch (CBValidationException $e) {
65
+        } catch (CBValidationException $e) {
62 66
             return cb()->redirect(cb()->getAdminUrl("login"),$e->getMessage(),'warning');
63 67
         }
64 68
     }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -20,29 +20,29 @@  discard block
 block discarded – undo
20 20
 
21 21
     public function getLogin()
22 22
     {
23
-        if(!auth()->guest()) return redirect(cb()->getAdminUrl());
23
+        if (!auth()->guest()) return redirect(cb()->getAdminUrl());
24 24
 
25 25
         cbHook()->hookGetLogin();
26 26
 
27 27
         $data = [];
28
-        $data['no1'] = rand(1,10);
29
-        $data['no2'] = rand(1,10);
30
-        Session::put("captcha_result", $data['no1']+$data['no2']);
28
+        $data['no1'] = rand(1, 10);
29
+        $data['no2'] = rand(1, 10);
30
+        Session::put("captcha_result", $data['no1'] + $data['no2']);
31 31
 
32
-        return view( str_replace(".blade.php", "", getSetting('login_page_view','crudbooster::login')), $data );
32
+        return view(str_replace(".blade.php", "", getSetting('login_page_view', 'crudbooster::login')), $data);
33 33
     }
34 34
 
35 35
     public function postLogin()
36 36
     {
37
-        try{
38
-            if($this->isSuspendedLogin()) throw new CBValidationException(cbLang("you_have_been_suspended"));
37
+        try {
38
+            if ($this->isSuspendedLogin()) throw new CBValidationException(cbLang("you_have_been_suspended"));
39 39
 
40 40
             cb()->validation([
41 41
                 'email'=>'required|email',
42 42
                 'password'=>'required'
43 43
             ]);
44 44
 
45
-            $credential = request()->only(['email','password']);
45
+            $credential = request()->only(['email', 'password']);
46 46
             if (auth()->attempt($credential)) {
47 47
 
48 48
                 // When login user success, clear suspend attempt
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
                 return redirect(cb()->getAdminUrl());
54 54
             } else {
55 55
                 $this->incrementFailedLogin();
56
-                return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'),'message_type'=>'warning']);
56
+                return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'), 'message_type'=>'warning']);
57 57
             }
58
-        }catch (CBValidationException $e) {
59
-            return cb()->redirect(cb()->getAdminUrl("login"),$e->getMessage(),'warning');
58
+        } catch (CBValidationException $e) {
59
+            return cb()->redirect(cb()->getAdminUrl("login"), $e->getMessage(), 'warning');
60 60
         }
61 61
     }
62 62
 
Please login to merge, or discard this patch.
src/controllers/DeveloperPluginStoreController.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
 
29 29
     public function getIndex() {
30 30
 
31
-        if(request("refresh")) {
32
-            $this->fetchPluginData(false );
33
-            return cb()->redirectBack("Plugin list has been refreshed!","success");
31
+        if (request("refresh")) {
32
+            $this->fetchPluginData(false);
33
+            return cb()->redirectBack("Plugin list has been refreshed!", "success");
34 34
         }
35 35
 
36 36
         $data = [];
37 37
         $data['result'] = $this->fetchPluginData();
38
-        return view($this->view.'.index',$data);
38
+        return view($this->view.'.index', $data);
39 39
     }
40 40
 
41 41
     public function postLoginAccount() {
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
         ]);
51 51
         $response = $curl->send();
52 52
 
53
-        if($respArray = json_decode($response, true)) {
54
-            if($respArray['status'] && isset($respArray['token'])) {
53
+        if ($respArray = json_decode($response, true)) {
54
+            if ($respArray['status'] && isset($respArray['token'])) {
55 55
                 session(['account_token'=>$respArray['token']]);
56 56
             }
57
-            return response()->make($response,200,["Content-Type"=>"application/json"]);
57
+            return response()->make($response, 200, ["Content-Type"=>"application/json"]);
58 58
         } else {
59
-            return response()->json(['status'=>false,'message'=>'failed']);
59
+            return response()->json(['status'=>false, 'message'=>'failed']);
60 60
         }
61 61
     }
62 62
 
@@ -73,15 +73,15 @@  discard block
 block discarded – undo
73 73
         ]);
74 74
         $response = $curl->send();
75 75
 
76
-        if($respArray = json_decode($response, true)) {
77
-            if($respArray['status']) {
76
+        if ($respArray = json_decode($response, true)) {
77
+            if ($respArray['status']) {
78 78
                 $form = base64_decode($respArray['payment']);
79
-                return response()->json(['status'=>true,'form'=>$form]);
79
+                return response()->json(['status'=>true, 'form'=>$form]);
80 80
             } else {
81 81
                 return response()->json($respArray);
82 82
             }
83 83
         } else {
84
-            return response()->json(['status'=>false,'message'=>'failed','raw'=>$response]);
84
+            return response()->json(['status'=>false, 'message'=>'failed', 'raw'=>$response]);
85 85
         }
86 86
     }
87 87
 
@@ -89,15 +89,15 @@  discard block
 block discarded – undo
89 89
     {
90 90
         $pluginData = $this->fetchPluginData();
91 91
 
92
-        if(isset($pluginData[$key])) {
93
-            if(file_exists(app_path("CBPlugins/".$key))) {
92
+        if (isset($pluginData[$key])) {
93
+            if (file_exists(app_path("CBPlugins/".$key))) {
94 94
                 rrmdir(app_path("CBPlugins/".$key));
95 95
                 return response()->json(['status'=>true, 'message'=>'Plugin has been uninstalled!']);
96
-            }else{
97
-                return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin is not found']);
96
+            } else {
97
+                return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin is not found']);
98 98
             }
99
-        }else {
100
-            return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin key is not found']);
99
+        } else {
100
+            return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin key is not found']);
101 101
         }
102 102
     }
103 103
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     {
106 106
         $pluginData = $this->fetchPluginData();
107 107
 
108
-        if(isset($pluginData[$key])) {
108
+        if (isset($pluginData[$key])) {
109 109
             $plugin = $pluginData[$key];
110 110
 
111 111
             // Create temp file of zip plugin
@@ -123,22 +123,22 @@  discard block
 block discarded – undo
123 123
                 fclose($temp);
124 124
 
125 125
                 // Rename
126
-                if(file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key));
126
+                if (file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key));
127 127
                 rename(app_path("CBPlugins/".$dirName), app_path("CBPlugins/".$key));
128 128
 
129
-                return response()->json(['status'=>true,'message'=>'Install / update plugin has been succesfull!']);
129
+                return response()->json(['status'=>true, 'message'=>'Install / update plugin has been succesfull!']);
130 130
 
131 131
             } else {
132
-                return response()->json(['status'=>false,'message'=>"Failed to install/update, can't open the plugin archive"]);
132
+                return response()->json(['status'=>false, 'message'=>"Failed to install/update, can't open the plugin archive"]);
133 133
             }
134
-        }else{
135
-            return response()->json(['status'=>false,'message'=>'Failed to install/update, plugin key is not found']);
134
+        } else {
135
+            return response()->json(['status'=>false, 'message'=>'Failed to install/update, plugin key is not found']);
136 136
         }
137 137
     }
138 138
 
139 139
     private function fetchPluginData($cache = true)
140 140
     {
141
-        if($cache === true && $data = Cache::get("plugin_store_data")) {
141
+        if ($cache === true && $data = Cache::get("plugin_store_data")) {
142 142
             return $data;
143 143
         }
144 144
 
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
             $context = stream_context_create($opts);
156 156
             $data = file_get_contents(base64_decode("aHR0cDovL2NydWRib29zdGVyLmNvbS9hcGkvcGx1Z2luP2FjY2Vzc190b2tlbj1iVmMvWm5wWU5TWnJNVlpZT0hFNVUydHFjU1U9"), false, $context);
157 157
 
158
-            if($data) {
158
+            if ($data) {
159 159
                 $data = json_decode($data, true);
160
-                if($data['status']==true) {
160
+                if ($data['status'] == true) {
161 161
 
162
-                    foreach($data['data'] as $item) {
162
+                    foreach ($data['data'] as $item) {
163 163
                         $key = $item['key'];
164
-                        $result[ $key ] = $item;
164
+                        $result[$key] = $item;
165 165
                     }
166 166
 
167 167
                     $result = collect($result)->sortBy("name")->all();
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
             if(file_exists(app_path("CBPlugins/".$key))) {
94 94
                 rrmdir(app_path("CBPlugins/".$key));
95 95
                 return response()->json(['status'=>true, 'message'=>'Plugin has been uninstalled!']);
96
-            }else{
96
+            } else{
97 97
                 return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin is not found']);
98 98
             }
99
-        }else {
99
+        } else {
100 100
             return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin key is not found']);
101 101
         }
102 102
     }
@@ -123,7 +123,9 @@  discard block
 block discarded – undo
123 123
                 fclose($temp);
124 124
 
125 125
                 // Rename
126
-                if(file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key));
126
+                if(file_exists(app_path("CBPlugins/".$key))) {
127
+                    rrmdir(app_path("CBPlugins/".$key));
128
+                }
127 129
                 rename(app_path("CBPlugins/".$dirName), app_path("CBPlugins/".$key));
128 130
 
129 131
                 return response()->json(['status'=>true,'message'=>'Install / update plugin has been succesfull!']);
@@ -131,7 +133,7 @@  discard block
 block discarded – undo
131 133
             } else {
132 134
                 return response()->json(['status'=>false,'message'=>"Failed to install/update, can't open the plugin archive"]);
133 135
             }
134
-        }else{
136
+        } else{
135 137
             return response()->json(['status'=>false,'message'=>'Failed to install/update, plugin key is not found']);
136 138
         }
137 139
     }
Please login to merge, or discard this patch.
src/helpers/Helper.php 3 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -220,20 +220,20 @@  discard block
 block discarded – undo
220 220
 }
221 221
 
222 222
 if(!function_exists('extract_unit')) {	
223
-	/*
223
+    /*
224 224
 	Credits: Bit Repository
225 225
 	URL: http://www.bitrepository.com/extract-content-between-two-delimiters-with-php.html
226 226
 	*/
227
-	function extract_unit($string, $start, $end)
228
-	{
229
-	$pos = stripos($string, $start);
230
-	$str = substr($string, $pos);
231
-	$str_two = substr($str, strlen($start));
232
-	$second_pos = stripos($str_two, $end);
233
-	$str_three = substr($str_two, 0, $second_pos);
234
-	$unit = trim($str_three); // remove whitespaces
235
-	return $unit;
236
-	}
227
+    function extract_unit($string, $start, $end)
228
+    {
229
+    $pos = stripos($string, $start);
230
+    $str = substr($string, $pos);
231
+    $str_two = substr($str, strlen($start));
232
+    $second_pos = stripos($str_two, $end);
233
+    $str_three = substr($str_two, 0, $second_pos);
234
+    $unit = trim($str_three); // remove whitespaces
235
+    return $unit;
236
+    }
237 237
 }
238 238
 
239 239
 /* 
@@ -407,22 +407,22 @@  discard block
 block discarded – undo
407 407
 }
408 408
 
409 409
 if(!function_exists('rrmdir')) {
410
-	/*
410
+    /*
411 411
 	* http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir
412 412
 	*/
413
-	function rrmdir($dir) { 
414
-	   if (is_dir($dir)) { 
415
-	     $objects = scandir($dir); 
416
-	     foreach ($objects as $object) { 
417
-	       if ($object != "." && $object != "..") { 
418
-	         if (is_dir($dir."/".$object))
419
-	           rrmdir($dir."/".$object);
420
-	         else
421
-	           unlink($dir."/".$object); 
422
-	       } 
423
-	     }
424
-	     rmdir($dir); 
425
-	   } 
426
-	 }
413
+    function rrmdir($dir) { 
414
+        if (is_dir($dir)) { 
415
+            $objects = scandir($dir); 
416
+            foreach ($objects as $object) { 
417
+            if ($object != "." && $object != "..") { 
418
+                if (is_dir($dir."/".$object))
419
+                rrmdir($dir."/".$object);
420
+                else
421
+                unlink($dir."/".$object); 
422
+            } 
423
+            }
424
+            rmdir($dir); 
425
+        } 
426
+        }
427 427
 }
428 428
 
Please login to merge, or discard this patch.
Spacing   +68 added lines, -68 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("makeReferalUrl")) {
3
+if (!function_exists("makeReferalUrl")) {
4 4
     function makeReferalUrl($name = null, $additionalVariables = []) {
5 5
         $ref = [];
6 6
         $ref['url'] = request()->fullUrl();
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
         $ref['additional'] = $additionalVariables;
9 9
         $md5Hash = md5(serialize($ref));
10 10
 
11
-        if($exist = \Illuminate\Support\Facades\Cache::get("refurl_".$md5Hash)) {
11
+        if ($exist = \Illuminate\Support\Facades\Cache::get("refurl_".$md5Hash)) {
12 12
             return $exist['id'];
13 13
         }
14 14
 
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
     }
21 21
 }
22 22
 
23
-if(!function_exists("getReferalUrl")) {
23
+if (!function_exists("getReferalUrl")) {
24 24
     function getReferalUrl($key = null) {
25
-        if(verifyReferalUrl()) {
25
+        if (verifyReferalUrl()) {
26 26
             $md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref"));
27 27
             $ref = \Illuminate\Support\Facades\Cache::get("refurl_".$md5hash);
28
-            if($key) {
28
+            if ($key) {
29 29
                 return $ref[$key];
30 30
             } else {
31 31
                 return $ref;
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
     }
36 36
 }
37 37
 
38
-if(!function_exists("verifyReferalUrl")) {
38
+if (!function_exists("verifyReferalUrl")) {
39 39
     function verifyReferalUrl()
40 40
     {
41
-        if(request("ref")) {
42
-            if($md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref"))) {
41
+        if (request("ref")) {
42
+            if ($md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref"))) {
43 43
                 $ref = \Illuminate\Support\Facades\Cache::get("refurl_".$md5hash);
44
-                if(filter_var($ref['url'], FILTER_VALIDATE_URL)) {
44
+                if (filter_var($ref['url'], FILTER_VALIDATE_URL)) {
45 45
                     return true;
46 46
                 }
47 47
             }
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     }
51 51
 }
52 52
 
53
-if(!function_exists("findModuleByPermalink")) {
53
+if (!function_exists("findModuleByPermalink")) {
54 54
     /**
55 55
      * @param string $permalink
56 56
      * @return \crocodicstudio\crudbooster\controllers\CBController|null
@@ -58,25 +58,25 @@  discard block
 block discarded – undo
58 58
     function findControllerByPermalink($permalink) {
59 59
         try {
60 60
             $controllers = glob(app_path('Http/Controllers/Admin*Controller.php'));
61
-            foreach($controllers as $controller) {
61
+            foreach ($controllers as $controller) {
62 62
                 $controllerName = basename($controller);
63
-                $controllerName = rtrim($controllerName,".php");
63
+                $controllerName = rtrim($controllerName, ".php");
64 64
                 $className = '\App\Http\Controllers\\'.$controllerName;
65 65
                 $controllerClass = new $className();
66
-                if(method_exists($controllerClass, 'cbInit')) {
67
-                    if($permalink == $controllerClass->getData('permalink')) {
66
+                if (method_exists($controllerClass, 'cbInit')) {
67
+                    if ($permalink == $controllerClass->getData('permalink')) {
68 68
                         return $controllerClass;
69 69
                     }
70 70
                 }
71 71
             }
72
-        }catch (\Exception $e) {
72
+        } catch (\Exception $e) {
73 73
 
74 74
         }
75 75
         return null;
76 76
     }
77 77
 }
78 78
 
79
-if(!function_exists("putHtaccess")) {
79
+if (!function_exists("putHtaccess")) {
80 80
     function putHtaccess($stringToPut)
81 81
     {
82 82
         file_put_contents(base_path(".htaccess"), "\n".$stringToPut, FILE_APPEND);
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
     }
85 85
 }
86 86
 
87
-if(!function_exists("checkHtaccess")) {
87
+if (!function_exists("checkHtaccess")) {
88 88
     function checkHtaccess($stringToCheck)
89 89
     {
90
-        if(file_exists(base_path(".htaccess")) && file_exists(public_path(".htaccess"))) {
90
+        if (file_exists(base_path(".htaccess")) && file_exists(public_path(".htaccess"))) {
91 91
             $htaccess = file_get_contents(base_path(".htaccess"));
92
-            $htaccess2= file_get_contents(public_path(".htaccess"));
93
-            if(\Illuminate\Support\Str::contains($htaccess, $stringToCheck) && \Illuminate\Support\Str::contains($htaccess2, $stringToCheck)) {
92
+            $htaccess2 = file_get_contents(public_path(".htaccess"));
93
+            if (\Illuminate\Support\Str::contains($htaccess, $stringToCheck) && \Illuminate\Support\Str::contains($htaccess2, $stringToCheck)) {
94 94
                 return true;
95 95
             }
96 96
         }
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     }
100 100
 }
101 101
 
102
-if(!function_exists("setEnvironmentValue")) {
102
+if (!function_exists("setEnvironmentValue")) {
103 103
     function setEnvironmentValue(array $values)
104 104
     {
105 105
         $envFile = app()->environmentFilePath();
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 }
131 131
 
132 132
 
133
-if(!function_exists("cbLang")) {
133
+if (!function_exists("cbLang")) {
134 134
     /**
135 135
      * @param string $key
136 136
      * @param array $replace
@@ -142,17 +142,17 @@  discard block
 block discarded – undo
142 142
     }
143 143
 }
144 144
 
145
-if(!function_exists('rglob')) {
145
+if (!function_exists('rglob')) {
146 146
     function rglob($pattern, $flags = 0) {
147 147
         $files = glob($pattern, $flags);
148
-        foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
148
+        foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
149 149
             $files = array_merge($files, rglob($dir.'/'.basename($pattern), $flags));
150 150
         }
151 151
         return $files;
152 152
     }
153 153
 }
154 154
 
155
-if(!function_exists('convertPHPToMomentFormat')) {
155
+if (!function_exists('convertPHPToMomentFormat')) {
156 156
     function convertPHPToMomentFormat($format)
157 157
     {
158 158
         $replacements = [
@@ -199,13 +199,13 @@  discard block
 block discarded – undo
199 199
     }
200 200
 }
201 201
 
202
-if(!function_exists('slug')) {
202
+if (!function_exists('slug')) {
203 203
     function slug($string, $separator = '-') {
204 204
         return \Illuminate\Support\Str::slug($string, $separator);
205 205
     }
206 206
 }
207 207
 
208
-if(!function_exists('columnSingleton')) {
208
+if (!function_exists('columnSingleton')) {
209 209
     /**
210 210
      * @return \crocodicstudio\crudbooster\controllers\scaffolding\singletons\ColumnSingleton
211 211
      */
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
     }
215 215
 }
216 216
 
217
-if(!function_exists('cbHook'))
217
+if (!function_exists('cbHook'))
218 218
 {
219 219
     /**
220 220
      * @return crocodicstudio\crudbooster\hooks\CBHook
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
     }
227 227
 }
228 228
 
229
-if(!function_exists('getTypeHook'))
229
+if (!function_exists('getTypeHook'))
230 230
 {
231 231
     /**
232 232
      * @param string $type
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
     }
240 240
 }
241 241
 
242
-if(!function_exists('getPrimaryKey'))
242
+if (!function_exists('getPrimaryKey'))
243 243
 {
244 244
     function getPrimaryKey($table_name)
245 245
     {
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
     }
248 248
 }
249 249
 
250
-if(!function_exists('cb'))
250
+if (!function_exists('cb'))
251 251
 {
252 252
     function cb()
253 253
     {
@@ -255,25 +255,25 @@  discard block
 block discarded – undo
255 255
     }
256 256
 }
257 257
 
258
-if(!function_exists('cbAsset')) {
258
+if (!function_exists('cbAsset')) {
259 259
     function cbAsset($path, $secure = null) {
260 260
         return asset("cb_asset/".$path, $secure);
261 261
     }
262 262
 }
263 263
 
264
-if(!function_exists("cbConfig")) {
264
+if (!function_exists("cbConfig")) {
265 265
     function cbConfig($name, $default = null) {
266 266
         return config("crudbooster.".$name, $default);
267 267
     }
268 268
 }
269 269
 
270
-if(!function_exists("strRandom")) {
270
+if (!function_exists("strRandom")) {
271 271
     function strRandom($length = 5) {
272 272
         return \Illuminate\Support\Str::random($length);
273 273
     }
274 274
 }
275 275
 
276
-if(!function_exists('module')) {
276
+if (!function_exists('module')) {
277 277
     function module()
278 278
     {
279 279
         $module = new \crocodicstudio\crudbooster\helpers\Module();
@@ -281,21 +281,21 @@  discard block
 block discarded – undo
281 281
     }
282 282
 }
283 283
 
284
-if(!function_exists('getAdminLoginURL')) {
284
+if (!function_exists('getAdminLoginURL')) {
285 285
     function getAdminLoginURL()
286 286
     {
287 287
         return cb()->getAdminUrl("login");
288 288
     }
289 289
 }
290 290
 
291
-if(!function_exists('dummyPhoto')) {
291
+if (!function_exists('dummyPhoto')) {
292 292
     function dummyPhoto()
293 293
     {
294 294
         return cbConfig("DUMMY_PHOTO");
295 295
     }
296 296
 }
297 297
 
298
-if(!function_exists('extract_unit')) {	
298
+if (!function_exists('extract_unit')) {	
299 299
 	/*
300 300
 	Credits: Bit Repository
301 301
 	URL: http://www.bitrepository.com/extract-content-between-two-delimiters-with-php.html
@@ -320,14 +320,14 @@  discard block
 block discarded – undo
320 320
 |
321 321
 */
322 322
 
323
-if(!function_exists('putSetting')) {
323
+if (!function_exists('putSetting')) {
324 324
     function putSetting($key, $value)
325 325
     {
326
-        if(file_exists(storage_path('.cbconfig'))) {
326
+        if (file_exists(storage_path('.cbconfig'))) {
327 327
             $settings = file_get_contents(storage_path('.cbconfig'));
328 328
             $settings = decrypt($settings);
329 329
             $settings = unserialize($settings);
330
-        }else{
330
+        } else {
331 331
             $settings = [];
332 332
         }
333 333
 
@@ -341,31 +341,31 @@  discard block
 block discarded – undo
341 341
     }
342 342
 }
343 343
 
344
-if(!function_exists('getSetting')) {
344
+if (!function_exists('getSetting')) {
345 345
     function getSetting($key, $default = null)
346 346
     {
347
-        if($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) {
347
+        if ($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) {
348 348
             return $cache;
349 349
         }
350 350
 
351
-        if(file_exists(storage_path('.cbconfig'))) {
351
+        if (file_exists(storage_path('.cbconfig'))) {
352 352
             $settings = file_get_contents(storage_path('.cbconfig'));
353 353
             $settings = decrypt($settings);
354 354
             $settings = unserialize($settings);
355
-        }else{
355
+        } else {
356 356
             $settings = [];
357 357
         }
358 358
 
359
-        if(isset($settings[$key])) {
359
+        if (isset($settings[$key])) {
360 360
             \Illuminate\Support\Facades\Cache::forever("setting_".$key, $settings[$key]);
361
-            return $settings[$key]?:$default;
362
-        }else{
361
+            return $settings[$key] ?: $default;
362
+        } else {
363 363
             return $default;
364 364
         }
365 365
     }
366 366
 }
367 367
 
368
-if(!function_exists('timeAgo')) {
368
+if (!function_exists('timeAgo')) {
369 369
     function timeAgo($datetime_to, $datetime_from = null, $full = false)
370 370
     {
371 371
         $datetime_from = ($datetime_from) ?: date('Y-m-d H:i:s');
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
             }
397 397
         }
398 398
 
399
-        if (! $full) {
399
+        if (!$full) {
400 400
             $string = array_slice($string, 0, 1);
401 401
         }
402 402
 
@@ -404,22 +404,22 @@  discard block
 block discarded – undo
404 404
     }
405 405
 }
406 406
 
407
-if(!function_exists("array_map_r")) {
408
-    function array_map_r( $func, $arr )
407
+if (!function_exists("array_map_r")) {
408
+    function array_map_r($func, $arr)
409 409
     {
410 410
         $newArr = array();
411 411
 
412
-        foreach( $arr as $key => $value )
412
+        foreach ($arr as $key => $value)
413 413
         {
414 414
             $key = $func($key);
415
-            $newArr[ $key ] = ( is_array( $value ) ? array_map_r( $func, $value ) : ( is_array($func) ? call_user_func_array($func, $value) : $func( $value ) ) );
415
+            $newArr[$key] = (is_array($value) ? array_map_r($func, $value) : (is_array($func) ? call_user_func_array($func, $value) : $func($value)));
416 416
         }
417 417
 
418 418
         return $newArr;
419 419
     }
420 420
 }
421 421
 
422
-if(!function_exists("sanitizeXSS"))
422
+if (!function_exists("sanitizeXSS"))
423 423
 {
424 424
     function sanitizeXSS($value)
425 425
     {
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
     }
432 432
 }
433 433
 
434
-if(!function_exists("requestAll")) {
434
+if (!function_exists("requestAll")) {
435 435
     function requestAll() {
436 436
         $all = array_map_r("sanitizeXSS", request()->all());
437 437
         return $all;
@@ -440,22 +440,22 @@  discard block
 block discarded – undo
440 440
 
441 441
 
442 442
 
443
-if(!function_exists('getURLFormat')) {
443
+if (!function_exists('getURLFormat')) {
444 444
     function getURLFormat($name) {
445 445
         $url = request($name);
446
-        if(filter_var($url, FILTER_VALIDATE_URL)) {
446
+        if (filter_var($url, FILTER_VALIDATE_URL)) {
447 447
             return $url;
448
-        }else{
448
+        } else {
449 449
             return request()->url();
450 450
         }
451 451
     }
452 452
 }
453 453
 
454
-if(!function_exists('g')) {
454
+if (!function_exists('g')) {
455 455
     function g($name, $safe = true) {
456
-        if($safe == true) {
456
+        if ($safe == true) {
457 457
             $response = request($name);
458
-            if(is_string($response)) {
458
+            if (is_string($response)) {
459 459
                 $response = sanitizeXSS($response);
460 460
             }elseif (is_array($response)) {
461 461
                 array_walk_recursive($response, function(&$response) {
@@ -464,25 +464,25 @@  discard block
 block discarded – undo
464 464
             }
465 465
 
466 466
             return $response;
467
-        }else{
467
+        } else {
468 468
             return Request::get($name);
469 469
         }
470 470
     }
471 471
 }
472 472
 
473
-if(!function_exists('min_var_export')) {
473
+if (!function_exists('min_var_export')) {
474 474
     function min_var_export($input) {
475
-        if(is_array($input)) {
475
+        if (is_array($input)) {
476 476
             $buffer = [];
477
-            foreach($input as $key => $value)
477
+            foreach ($input as $key => $value)
478 478
                 $buffer[] = var_export($key, true)."=>".min_var_export($value);
479
-            return "[".implode(",",$buffer)."]";
479
+            return "[".implode(",", $buffer)."]";
480 480
         } else
481 481
             return var_export($input, true);
482 482
     }
483 483
 }
484 484
 
485
-if(!function_exists('rrmdir')) {
485
+if (!function_exists('rrmdir')) {
486 486
 	/*
487 487
 	* http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir
488 488
 	*/
Please login to merge, or discard this patch.
Braces   +21 added lines, -16 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
                     }
70 70
                 }
71 71
             }
72
-        }catch (\Exception $e) {
72
+        } catch (\Exception $e) {
73 73
 
74 74
         }
75 75
         return null;
@@ -124,7 +124,9 @@  discard block
 block discarded – undo
124 124
         }
125 125
 
126 126
         $str = substr($str, 0, -1);
127
-        if (!file_put_contents($envFile, $str)) return false;
127
+        if (!file_put_contents($envFile, $str)) {
128
+            return false;
129
+        }
128 130
         return true;
129 131
     }
130 132
 }
@@ -327,7 +329,7 @@  discard block
 block discarded – undo
327 329
             $settings = file_get_contents(storage_path('.cbconfig'));
328 330
             $settings = decrypt($settings);
329 331
             $settings = unserialize($settings);
330
-        }else{
332
+        } else{
331 333
             $settings = [];
332 334
         }
333 335
 
@@ -352,14 +354,14 @@  discard block
 block discarded – undo
352 354
             $settings = file_get_contents(storage_path('.cbconfig'));
353 355
             $settings = decrypt($settings);
354 356
             $settings = unserialize($settings);
355
-        }else{
357
+        } else{
356 358
             $settings = [];
357 359
         }
358 360
 
359 361
         if(isset($settings[$key])) {
360 362
             \Illuminate\Support\Facades\Cache::forever("setting_".$key, $settings[$key]);
361 363
             return $settings[$key]?:$default;
362
-        }else{
364
+        } else{
363 365
             return $default;
364 366
         }
365 367
     }
@@ -445,7 +447,7 @@  discard block
 block discarded – undo
445 447
         $url = request($name);
446 448
         if(filter_var($url, FILTER_VALIDATE_URL)) {
447 449
             return $url;
448
-        }else{
450
+        } else{
449 451
             return request()->url();
450 452
         }
451 453
     }
@@ -457,14 +459,14 @@  discard block
 block discarded – undo
457 459
             $response = request($name);
458 460
             if(is_string($response)) {
459 461
                 $response = sanitizeXSS($response);
460
-            }elseif (is_array($response)) {
462
+            } elseif (is_array($response)) {
461 463
                 array_walk_recursive($response, function(&$response) {
462 464
                     $response = sanitizeXSS($response);
463 465
                 });
464 466
             }
465 467
 
466 468
             return $response;
467
-        }else{
469
+        } else{
468 470
             return Request::get($name);
469 471
         }
470 472
     }
@@ -474,11 +476,13 @@  discard block
 block discarded – undo
474 476
     function min_var_export($input) {
475 477
         if(is_array($input)) {
476 478
             $buffer = [];
477
-            foreach($input as $key => $value)
478
-                $buffer[] = var_export($key, true)."=>".min_var_export($value);
479
+            foreach($input as $key => $value) {
480
+                            $buffer[] = var_export($key, true)."=>".min_var_export($value);
481
+            }
479 482
             return "[".implode(",",$buffer)."]";
480
-        } else
481
-            return var_export($input, true);
483
+        } else {
484
+                    return var_export($input, true);
485
+        }
482 486
     }
483 487
 }
484 488
 
@@ -491,10 +495,11 @@  discard block
 block discarded – undo
491 495
 	     $objects = scandir($dir); 
492 496
 	     foreach ($objects as $object) { 
493 497
 	       if ($object != "." && $object != "..") { 
494
-	         if (is_dir($dir."/".$object))
495
-	           rrmdir($dir."/".$object);
496
-	         else
497
-	           unlink($dir."/".$object); 
498
+	         if (is_dir($dir."/".$object)) {
499
+	         	           rrmdir($dir."/".$object);
500
+	         } else {
501
+	         	           unlink($dir."/".$object);
502
+	         }
498 503
 	       } 
499 504
 	     }
500 505
 	     rmdir($dir); 
Please login to merge, or discard this patch.
src/helpers/CurlHelper.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
     public function headers(array $headers) {
27 27
         $newHeaders = [];
28
-        foreach($headers as $key=>$val) {
28
+        foreach ($headers as $key=>$val) {
29 29
             $newHeaders[] = $key.": ".$val;
30 30
         }
31 31
         $this->headers = $newHeaders;
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
         $err = curl_error($ch);
48 48
         curl_close($ch);
49 49
 
50
-        if($err) {
50
+        if ($err) {
51 51
             return $err;
52
-        }else {
52
+        } else {
53 53
             return $response;
54 54
         }
55 55
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
 
50 50
         if($err) {
51 51
             return $err;
52
-        }else {
52
+        } else {
53 53
             return $response;
54 54
         }
55 55
     }
Please login to merge, or discard this patch.
src/commands/Install.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
         if ($this->confirm('Do you have setting the database configuration at .env ?')) {
41 41
 
42
-            if (! file_exists(public_path('vendor')) ) {
42
+            if (!file_exists(public_path('vendor'))) {
43 43
                 mkdir(public_path('vendor'));
44 44
             }
45 45
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             /*
53 53
              * Create CBPlugins
54 54
              */
55
-            if(!file_exists(app_path("CBPlugins"))) {
55
+            if (!file_exists(app_path("CBPlugins"))) {
56 56
                 mkdir(app_path("CBPlugins"));
57 57
             }
58 58
 
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
              * We need it to change default laravel local filesystem from storage to public
62 62
              * We won't use symlink because of a security issue in many server
63 63
              */
64
-            if(!file_exists(public_path("storage"))) {
64
+            if (!file_exists(public_path("storage"))) {
65 65
                 $this->info("Create storage directory on /public");
66 66
                 mkdir(public_path("storage"));
67
-                file_put_contents(public_path("storage/.gitignore"),"!.gitignore");
68
-                file_put_contents(public_path("storage/index.html"),"&nbsp;");
67
+                file_put_contents(public_path("storage/.gitignore"), "!.gitignore");
68
+                file_put_contents(public_path("storage/index.html"), "&nbsp;");
69 69
             }
70 70
 
71 71
             /*
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
              * Disable php execution on /vendor/*
75 75
              */
76 76
             $this->info("Tweak some security for your laravel");
77
-            file_put_contents(base_path(".htaccess"), "\n\n# Generated by CRUDBooster\nServerSignature Off\nIndexIgnore *\nRewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]\nRewriteRule ^vendor/.*\.(php|rb|py)$ - [F,L,NC]\n<FilesMatch \"^\.\">\nOrder allow,deny\nDeny from all\n</FilesMatch>",FILE_APPEND);
78
-            file_put_contents(public_path(".htaccess"), "\n\n# Generated by CRUDBooster\nServerSignature Off\nIndexIgnore *\nRewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]\nRewriteRule ^vendor/.*\.(php|rb|py)$ - [F,L,NC]\n<FilesMatch \"^\.\">\nOrder allow,deny\nDeny from all\n</FilesMatch>",FILE_APPEND);
77
+            file_put_contents(base_path(".htaccess"), "\n\n# Generated by CRUDBooster\nServerSignature Off\nIndexIgnore *\nRewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]\nRewriteRule ^vendor/.*\.(php|rb|py)$ - [F,L,NC]\n<FilesMatch \"^\.\">\nOrder allow,deny\nDeny from all\n</FilesMatch>", FILE_APPEND);
78
+            file_put_contents(public_path(".htaccess"), "\n\n# Generated by CRUDBooster\nServerSignature Off\nIndexIgnore *\nRewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]\nRewriteRule ^vendor/.*\.(php|rb|py)$ - [F,L,NC]\n<FilesMatch \"^\.\">\nOrder allow,deny\nDeny from all\n</FilesMatch>", FILE_APPEND);
79 79
 
80 80
 
81 81
             $this->info('Dumping the autoloaded files and reloading all new files...');
Please login to merge, or discard this patch.
src/routes.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
     if (Request::is(cb()->getAdminPath())) {
59 59
         if($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) {
60 60
             cb()->routeGet("/", $dashboard);
61
-        }else{
61
+        } else{
62 62
             cb()->routeGet("/", "\crocodicstudio\crudbooster\controllers\AdminDashboardController@getIndex");
63 63
         }
64 64
     }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -1,58 +1,58 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Developer Backend Middleware
4
-Route::group(['middleware' => ['web',\crocodicstudio\crudbooster\middlewares\CBDeveloper::class],
4
+Route::group(['middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBDeveloper::class],
5 5
     'prefix'=>"developer/".getSetting('developer_path'),
6
-    'namespace' => 'crocodicstudio\crudbooster\controllers'], function () {
6
+    'namespace' => 'crocodicstudio\crudbooster\controllers'], function() {
7 7
     cb()->routeController("modules", "\crocodicstudio\crudbooster\controllers\DeveloperModulesController");
8 8
     cb()->routeController("menus", "\crocodicstudio\crudbooster\controllers\DeveloperMenusController");
9
-    cb()->routeController("roles","\crocodicstudio\crudbooster\controllers\DeveloperRolesController");
10
-    cb()->routeController("users","\crocodicstudio\crudbooster\controllers\DeveloperUsersController");
11
-    cb()->routeController("plugins","\crocodicstudio\crudbooster\controllers\DeveloperPluginStoreController");
12
-    cb()->routeController("mail","\crocodicstudio\crudbooster\controllers\DeveloperMailController");
13
-    cb()->routeController("security","\crocodicstudio\crudbooster\controllers\DeveloperSecurityController");
14
-    cb()->routeController("appearance","\crocodicstudio\crudbooster\controllers\DeveloperAppearanceController");
15
-    cb()->routeController("miscellaneous","\crocodicstudio\crudbooster\controllers\DeveloperMiscellaneousController");
16
-    cb()->routePost("skip-tutorial","DeveloperDashboardController@postSkipTutorial");
17
-    cb()->routeGet("/","DeveloperDashboardController@getIndex");
9
+    cb()->routeController("roles", "\crocodicstudio\crudbooster\controllers\DeveloperRolesController");
10
+    cb()->routeController("users", "\crocodicstudio\crudbooster\controllers\DeveloperUsersController");
11
+    cb()->routeController("plugins", "\crocodicstudio\crudbooster\controllers\DeveloperPluginStoreController");
12
+    cb()->routeController("mail", "\crocodicstudio\crudbooster\controllers\DeveloperMailController");
13
+    cb()->routeController("security", "\crocodicstudio\crudbooster\controllers\DeveloperSecurityController");
14
+    cb()->routeController("appearance", "\crocodicstudio\crudbooster\controllers\DeveloperAppearanceController");
15
+    cb()->routeController("miscellaneous", "\crocodicstudio\crudbooster\controllers\DeveloperMiscellaneousController");
16
+    cb()->routePost("skip-tutorial", "DeveloperDashboardController@postSkipTutorial");
17
+    cb()->routeGet("/", "DeveloperDashboardController@getIndex");
18 18
 });
19 19
 
20 20
 // Developer Auth Middleware
21 21
 Route::group(['middleware' => ['web'],
22 22
     'prefix'=>"developer/".getSetting('developer_path'),
23
-    'namespace' => 'crocodicstudio\crudbooster\controllers'], function () {
24
-    cb()->routePost("login","AdminAuthController@postLoginDeveloper");
25
-    cb()->routeGet("login","AdminAuthController@getLoginDeveloper");
26
-    cb()->routeGet("logout","AdminAuthController@getLogoutDeveloper");
23
+    'namespace' => 'crocodicstudio\crudbooster\controllers'], function() {
24
+    cb()->routePost("login", "AdminAuthController@postLoginDeveloper");
25
+    cb()->routeGet("login", "AdminAuthController@getLoginDeveloper");
26
+    cb()->routeGet("logout", "AdminAuthController@getLogoutDeveloper");
27 27
 });
28 28
 
29 29
 // Routing without any middleware
30
-Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function () {
31
-    if(getSetting("AUTO_REDIRECT_TO_LOGIN")) {
32
-        cb()->routeGet("/","AdminAuthController@getRedirectToLogin");
30
+Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function() {
31
+    if (getSetting("AUTO_REDIRECT_TO_LOGIN")) {
32
+        cb()->routeGet("/", "AdminAuthController@getRedirectToLogin");
33 33
     }
34 34
 });
35 35
 
36 36
 // Routing without any middleware with admin prefix
37
-Route::group(['middleware' => ['web'], 'prefix' => cb()->getAdminPath(), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function () {
37
+Route::group(['middleware' => ['web'], 'prefix' => cb()->getAdminPath(), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function() {
38 38
     cb()->routeGet('logout', "AdminAuthController@getLogout");
39 39
 
40
-    if(!getSetting("DISABLE_LOGIN")) {
40
+    if (!getSetting("DISABLE_LOGIN")) {
41 41
         cb()->routePost('login', "AdminAuthController@postLogin");
42 42
         cb()->routeGet('login', "AdminAuthController@getLogin");
43 43
     }
44 44
 
45
-    if(getSetting("enable_forget")) {
46
-        cb()->routePost("forget","AdminAuthController@postForget");
45
+    if (getSetting("enable_forget")) {
46
+        cb()->routePost("forget", "AdminAuthController@postForget");
47 47
     }
48 48
 
49
-    if(getSetting("enable_register")) {
50
-        cb()->routePost("register","AdminAuthController@postRegister");
49
+    if (getSetting("enable_register")) {
50
+        cb()->routePost("register", "AdminAuthController@postRegister");
51 51
     }
52 52
 });
53 53
 
54 54
 // Routing package controllers
55
-cb()->routeGroupBackend(function () {
55
+cb()->routeGroupBackend(function() {
56 56
     cb()->routeController('profile', '\crocodicstudio\crudbooster\controllers\AdminProfileController');
57 57
 });
58 58
 
@@ -61,24 +61,24 @@  discard block
 block discarded – undo
61 61
     'middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBBackend::class],
62 62
     'prefix' => cb()->getAdminPath(),
63 63
     'namespace' => 'App\Http\Controllers',
64
-], function () {
64
+], function() {
65 65
 
66 66
     if (Request::is(cb()->getAdminPath())) {
67
-        if($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) {
67
+        if ($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) {
68 68
             cb()->routeGet("/", $dashboard);
69
-        }else{
69
+        } else {
70 70
             cb()->routeGet("/", "\crocodicstudio\crudbooster\controllers\AdminDashboardController@getIndex");
71 71
         }
72 72
     }
73 73
 
74 74
     $controllers = glob(app_path('Http/Controllers/Admin*Controller.php'));
75 75
 
76
-    foreach($controllers as $controller) {
76
+    foreach ($controllers as $controller) {
77 77
         $controllerName = basename($controller);
78
-        $controllerName = rtrim($controllerName,".php");
78
+        $controllerName = rtrim($controllerName, ".php");
79 79
         $className = '\App\Http\Controllers\\'.$controllerName;
80 80
         $controllerClass = new $className();
81
-        if(method_exists($controllerClass, 'cbInit')) {
81
+        if (method_exists($controllerClass, 'cbInit')) {
82 82
             cb()->routeController($controllerClass->getData('permalink'), $controllerName);
83 83
         }
84 84
     }
Please login to merge, or discard this patch.
src/helpers/CB.php 2 patches
Spacing   +32 added lines, -32 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","&nbsp;","public");
92
-            Storage::put($file_path."/.gitignore","!.gitignore","public");
91
+            Storage::put($file_path."/index.html", "&nbsp;", "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
     }
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
         $validator = Validator::make($input_arr, $rules, $messages);
323 323
         if ($validator->fails()) {
324 324
             $message = $validator->errors()->all();
325
-            throw new CBValidationException(implode("; ",$message));
325
+            throw new CBValidationException(implode("; ", $message));
326 326
         }
327 327
     }
328 328
 
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
     public function findPrimaryKey($table)
335 335
     {
336 336
         $pk = DB::getDoctrineSchemaManager()->listTableDetails($table)->getPrimaryKey();
337
-        if(!$pk) {
337
+        if (!$pk) {
338 338
             return null;
339 339
         }
340 340
         return $pk->getColumns()[0];
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
             $string_parameters_array = explode('&', $string_parameters);
384 384
             foreach ($string_parameters_array as $s) {
385 385
                 $part = explode('=', $s);
386
-                if(isset($part[0]) && isset($part[1])) {
386
+                if (isset($part[0]) && isset($part[1])) {
387 387
                     $name = htmlspecialchars(urldecode($part[0]));
388 388
                     $name = strip_tags($name);
389 389
                     $value = htmlspecialchars(urldecode($part[1]));
@@ -400,16 +400,16 @@  discard block
 block discarded – undo
400 400
 
401 401
 
402 402
     public function routeGet($prefix, $controller) {
403
-        $alias = str_replace("@"," ", $controller);
403
+        $alias = str_replace("@", " ", $controller);
404 404
         $alias = ucwords($alias);
405
-        $alias = str_replace(" ","",$alias);
405
+        $alias = str_replace(" ", "", $alias);
406 406
         Route::get($prefix, ['uses' => $controller, 'as' => $alias]);
407 407
     }
408 408
 
409 409
     public function routePost($prefix, $controller) {
410
-        $alias = str_replace("@"," ", $controller);
410
+        $alias = str_replace("@", " ", $controller);
411 411
         $alias = ucwords($alias);
412
-        $alias = str_replace(" ","",$alias);
412
+        $alias = str_replace(" ", "", $alias);
413 413
         Route::post($prefix, ['uses' => $controller, 'as' => $alias]);
414 414
     }
415 415
 
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 
443 443
         $prefix = trim($prefix, '/').'/';
444 444
 
445
-        if(substr($controller,0,1) != "\\") {
445
+        if (substr($controller, 0, 1) != "\\") {
446 446
             $controller = "\App\Http\Controllers\\".$controller;
447 447
         }
448 448
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 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
     }
@@ -129,10 +129,10 @@  discard block
 block discarded – undo
129 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
     }
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/helpers/HTMLHelper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         $data['name'] = $name;
26 26
         $data['label'] = $label;
27 27
         $data['required'] = $required;
28
-        $data['encrypt'] = isset($options['encrypt'])?$options['encrypt']:true;
28
+        $data['encrypt'] = isset($options['encrypt']) ? $options['encrypt'] : true;
29 29
         return view("crudbooster::html_helper.file_uploader.index", $data);
30 30
     }
31 31
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         $data['name'] = $name;
43 43
         $data['label'] = $label;
44 44
         $data['required'] = $required;
45
-        $data['encrypt'] = isset($options['encrypt'])?$options['encrypt']:true;
45
+        $data['encrypt'] = isset($options['encrypt']) ? $options['encrypt'] : true;
46 46
         @$data['resizeWidth'] = $options['resize_width'];
47 47
         @$data['resizeHeight'] = $options['resize_height'];
48 48
         return view("crudbooster::html_helper.image_uploader.index", $data);
Please login to merge, or discard this patch.
src/types/file/Route.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-cb()->routeGroupBackend(function () {
4
-    cb()->routePost("upload-file",'\crocodicstudio\crudbooster\types\file\FileController@postUploadFile');
3
+cb()->routeGroupBackend(function() {
4
+    cb()->routePost("upload-file", '\crocodicstudio\crudbooster\types\file\FileController@postUploadFile');
5 5
 });
6 6
 
7
-cb()->routeGroupDeveloper(function () {
8
-    cb()->routePost("upload-file",'\crocodicstudio\crudbooster\types\file\FileController@postUploadFile');
7
+cb()->routeGroupDeveloper(function() {
8
+    cb()->routePost("upload-file", '\crocodicstudio\crudbooster\types\file\FileController@postUploadFile');
9 9
 });
10 10
\ No newline at end of file
Please login to merge, or discard this patch.