Passed
Push — master ( b43194...ce05c1 )
by Ferry
04:20
created
src/controllers/RegisterController.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -29,25 +29,25 @@  discard block
 block discarded – undo
29 29
                 "captcha"=>"required|integer"
30 30
             ]);
31 31
 
32
-            if(Session::get("captcha_result") != request("captcha")) {
32
+            if (Session::get("captcha_result") != request("captcha")) {
33 33
                 return cb()->redirectBack("The captcha that you input is wrong!");
34 34
             }
35 35
 
36
-            if($user = cb()->find("users",["email"=>request("email")])) {
36
+            if ($user = cb()->find("users", ["email"=>request("email")])) {
37 37
                 return cb()->redirectBack("The email you input has already exists!");
38 38
             }
39 39
 
40
-            if(getSetting("register_mail_verification")) {
41
-                Cache::put("register_".$token,[
40
+            if (getSetting("register_mail_verification")) {
41
+                Cache::put("register_".$token, [
42 42
                     "name"=>request("name"),
43 43
                     "email"=>request("email"),
44 44
                     "password"=>request("password")
45
-                ],now()->addHours(24));
45
+                ], now()->addHours(24));
46 46
 
47 47
                 $mail = new MailHelper();
48 48
                 $mail->to(request("email"));
49
-                $mail->sender(getSetting("register_mail_verification_sender","noreply@".$_SERVER['SERVER_NAME']),cb()->getAppName());
50
-                $mail->content("Verify Your Registration","
49
+                $mail->sender(getSetting("register_mail_verification_sender", "noreply@".$_SERVER['SERVER_NAME']), cb()->getAppName());
50
+                $mail->content("Verify Your Registration", "
51 51
                 Hi ".request("name")."<br/>
52 52
                 Thank you for register at ".cb()->getAppName()." to continue your registration, please click on the following link: <br/>
53 53
                 <p>$linkToken</p>
@@ -66,18 +66,18 @@  discard block
 block discarded – undo
66 66
                         "cb_roles_id"=> getSetting("register_as_role")
67 67
                     ]);
68 68
 
69
-                return cb()->redirect(cb()->getAdminUrl("login"),"Thank you for register. Now you can login to start your session :)","success");
69
+                return cb()->redirect(cb()->getAdminUrl("login"), "Thank you for register. Now you can login to start your session :)", "success");
70 70
             }
71 71
 
72
-        }catch (CBValidationException $e) {
72
+        } catch (CBValidationException $e) {
73 73
             return cb()->redirectBack($e->getMessage());
74 74
         }
75 75
 
76
-        return cb()->redirectBack("We've sent you an confirmation email. Please click the link inside the email","success");
76
+        return cb()->redirectBack("We've sent you an confirmation email. Please click the link inside the email", "success");
77 77
     }
78 78
 
79 79
     public function postContinueRegister($token) {
80
-        if($token = Cache::get("register_".$token)) {
80
+        if ($token = Cache::get("register_".$token)) {
81 81
             DB::table("users")
82 82
                 ->insert([
83 83
                     "created_at"=>date("Y-m-d H:i:s"),
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
                     "cb_roles_id"=> getSetting("register_as_role")
88 88
                 ]);
89 89
 
90
-            return cb()->redirect(cb()->getAdminUrl("login"),"Thank you for register. Now you can login to start your session :)","success");
90
+            return cb()->redirect(cb()->getAdminUrl("login"), "Thank you for register. Now you can login to start your session :)", "success");
91 91
         } else {
92
-            return cb()->redirect(cb()->getAdminUrl("login"),"It looks like the URL has been expired!");
92
+            return cb()->redirect(cb()->getAdminUrl("login"), "It looks like the URL has been expired!");
93 93
         }
94 94
     }
95 95
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
                 return cb()->redirect(cb()->getAdminUrl("login"),"Thank you for register. Now you can login to start your session :)","success");
70 70
             }
71 71
 
72
-        }catch (CBValidationException $e) {
72
+        } catch (CBValidationException $e) {
73 73
             return cb()->redirectBack($e->getMessage());
74 74
         }
75 75
 
Please login to merge, or discard this patch.
src/controllers/AuthSuspend.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@
 block discarded – undo
28 28
     {
29 29
         $key = md5(request()->ip().request()->userAgent());
30 30
 
31
-        if(Cache::has("loginSuspended".$key)) {
31
+        if (Cache::has("loginSuspended".$key)) {
32 32
             return true;
33 33
         }
34 34
 
35
-        if(getSetting("AUTO_SUSPEND_LOGIN") && Cache::get("loginFailed".$key) >= getSetting("AUTO_SUSPEND_LOGIN")) {
35
+        if (getSetting("AUTO_SUSPEND_LOGIN") && Cache::get("loginFailed".$key) >= getSetting("AUTO_SUSPEND_LOGIN")) {
36 36
             Cache::put("loginSuspended".$key, true, 30);
37 37
             $this->clearSuspendAttempt();
38 38
             return true;
Please login to merge, or discard this patch.
src/controllers/DeveloperMiscellaneousController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -24,19 +24,19 @@
 block discarded – undo
24 24
 
25 25
     public function getIndex() {
26 26
         $data = [];
27
-        return view($this->view.".index",$data);
27
+        return view($this->view.".index", $data);
28 28
     }
29 29
 
30 30
     public function postSave()
31 31
     {
32
-        foreach(request()->except("_token") as $key=>$val) {
33
-            putSetting( $key,  $val);
32
+        foreach (request()->except("_token") as $key=>$val) {
33
+            putSetting($key, $val);
34 34
         }
35 35
 
36
-        putSetting("enable_register",request("enable_register"));
36
+        putSetting("enable_register", request("enable_register"));
37 37
         putSetting("enable_forget", request("enable_forget"));
38 38
         putSetting("register_mail_verification", request("register_mail_verification"));
39 39
 
40
-        return cb()->redirectBack("Setting has been updated!","success");
40
+        return cb()->redirectBack("Setting has been updated!", "success");
41 41
     }
42 42
 }
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
src/controllers/ForgetController.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
         try {
25 25
             cb()->validation(['email'=>'required|email']);
26 26
 
27
-            if($user = cb()->find("users",["email"=>request("email")])) {
27
+            if ($user = cb()->find("users", ["email"=>request("email")])) {
28 28
                 $token = Str::random(6);
29 29
                 $linkToken = cb()->getAdminUrl("continue-reset/".$token);
30 30
                 Cache::put("forget_".$token, $user->id, now()->addHours(12));
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 
38 38
                 $mail = new MailHelper();
39 39
                 $mail->to($user->email);
40
-                $mail->sender(getSetting("forget_email_sender","noreply@".$_SERVER['SERVER_NAME']),cb()->getAppName());
41
-                $mail->content("Please Confirm Your Forgot Password","
40
+                $mail->sender(getSetting("forget_email_sender", "noreply@".$_SERVER['SERVER_NAME']), cb()->getAppName());
41
+                $mail->content("Please Confirm Your Forgot Password", "
42 42
                     Hi $user->name,<br/><br>
43 43
                     Someone with the detail bellow: <br/>
44 44
                     Time = ".now()->format("Y-m-d H:i:s")."<br/>
@@ -58,28 +58,28 @@  discard block
 block discarded – undo
58 58
                 return cb()->redirectBack("Your email is not registered");
59 59
             }
60 60
 
61
-        }catch (CBValidationException $e) {
61
+        } catch (CBValidationException $e) {
62 62
             return cb()->redirectBack($e->getMessage());
63 63
         } catch (\Exception $e) {
64 64
             Log::error($e);
65 65
             return cb()->redirectBack(cbLang("something_went_wrong"));
66 66
         }
67 67
 
68
-        return cb()->redirectBack("We've sent you an email instruction. Please follow the instruction inside the email","success");
68
+        return cb()->redirectBack("We've sent you an email instruction. Please follow the instruction inside the email", "success");
69 69
     }
70 70
 
71 71
     public function getContinueReset($token) {
72
-        if(Cache::has("forget_".$token)) {
72
+        if (Cache::has("forget_".$token)) {
73 73
             $id = Cache::get("forget_".$token);
74 74
             $newPassword = Str::random(6);
75 75
             cb()->update("users", $id, ["password"=>Hash::make($newPassword)]);
76 76
 
77
-            $user = cb()->find("users",$id);
77
+            $user = cb()->find("users", $id);
78 78
 
79 79
             $mail = new MailHelper();
80 80
             $mail->to($user->email);
81
-            $mail->sender(getSetting("forget_email_sender","noreply@".$_SERVER['SERVER_NAME']),cb()->getAppName());
82
-            $mail->content("This Is Your New Password","
81
+            $mail->sender(getSetting("forget_email_sender", "noreply@".$_SERVER['SERVER_NAME']), cb()->getAppName());
82
+            $mail->content("This Is Your New Password", "
83 83
                     Hi $user->name,<br/><br>
84 84
                     Thank you for confirming the request new password. Here is your new password: <br>
85 85
                     <h2>$newPassword</h2>
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
                 ");
91 91
             $mail->send();
92 92
 
93
-            return cb()->redirect(cb()->getAdminUrl("login"),"We've sent you new password email. Please check at your mail inbox or spambox","success");
93
+            return cb()->redirect(cb()->getAdminUrl("login"), "We've sent you new password email. Please check at your mail inbox or spambox", "success");
94 94
         } else {
95
-            return cb()->redirect(cb()->getAdminUrl("login"),"It looks like the url has been expired!");
95
+            return cb()->redirect(cb()->getAdminUrl("login"), "It looks like the url has been expired!");
96 96
         }
97 97
     }
98 98
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
                 return cb()->redirectBack("Your email is not registered");
59 59
             }
60 60
 
61
-        }catch (CBValidationException $e) {
61
+        } catch (CBValidationException $e) {
62 62
             return cb()->redirectBack($e->getMessage());
63 63
         } catch (\Exception $e) {
64 64
             Log::error($e);
Please login to merge, or discard this patch.
src/controllers/SubModuleController.php 2 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,12 @@
 block discarded – undo
14 14
 {
15 15
 
16 16
     public function getSubModule($subModuleKey) {
17
-        if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
18
-        if(!verifyReferalUrl()) return cb()->redirect(module()->url(),"It looks like your url is incorrect");
17
+        if(!module()->canBrowse()) {
18
+            return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
19
+        }
20
+        if(!verifyReferalUrl()) {
21
+            return cb()->redirect(module()->url(),"It looks like your url is incorrect");
22
+        }
19 23
 
20 24
         if($subModule = Cache::get("subModule".$subModuleKey)) {
21 25
             $foreignKey = $subModule['foreignKey'];
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@  discard block
 block discarded – undo
14 14
 {
15 15
 
16 16
     public function getSubModule($subModuleKey) {
17
-        if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
18
-        if(!verifyReferalUrl()) return cb()->redirect(module()->url(),"It looks like your url is incorrect");
17
+        if (!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area"));
18
+        if (!verifyReferalUrl()) return cb()->redirect(module()->url(), "It looks like your url is incorrect");
19 19
 
20
-        if($subModule = Cache::get("subModule".$subModuleKey)) {
20
+        if ($subModule = Cache::get("subModule".$subModuleKey)) {
21 21
             $foreignKey = $subModule['foreignKey'];
22 22
             $foreignValue = $subModule['foreignValue'];
23 23
 
24 24
             $query = $this->repository();
25 25
             $query->where($foreignKey, $foreignValue);
26
-            $result = $query->paginate( request("limit")?:$this->data["limit"] );
26
+            $result = $query->paginate(request("limit") ?: $this->data["limit"]);
27 27
             $data['result'] = $result;
28 28
 
29 29
             $data['additionalHeaderTitle'] = $subModule['parentTitle'];
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
             return view("crudbooster::module.index.index", array_merge($data, $this->data));
34 34
         }
35 35
 
36
-        return cb()->redirect(module()->url(),"It looks like your url is incorrect");
36
+        return cb()->redirect(module()->url(), "It looks like your url is incorrect");
37 37
     }
38 38
 
39 39
 }
40 40
\ No newline at end of file
Please login to merge, or discard this patch.
src/controllers/traits/ColumnIntervention.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@
 block discarded – undo
18 18
      */
19 19
     public function columnIntervention()
20 20
     {
21
-        if(request("sub_module") && Cache::has("subModule".request("sub_module")) && cb()->getCurrentMethod() != "getDetail") {
21
+        if (request("sub_module") && Cache::has("subModule".request("sub_module")) && cb()->getCurrentMethod() != "getDetail") {
22 22
             /*
23 23
              * If there is sub module, the column that has same name with foreign key should be remove
24 24
              * And change to hidden. So we can save the foreign Key id from the parent module.
25 25
              */
26 26
             $subModule = Cache::get("subModule".request("sub_module"));
27 27
             $this->removeColumn($subModule["foreignKey"])
28
-                ->addHidden($subModule["foreignKey"],$subModule['foreignKey'])
28
+                ->addHidden($subModule["foreignKey"], $subModule['foreignKey'])
29 29
                 ->defaultValue($subModule['foreignValue']);
30 30
         }
31 31
     }
Please login to merge, or discard this patch.
src/controllers/traits/ControllerSetting.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -202,13 +202,13 @@  discard block
 block discarded – undo
202 202
         $parentPath = $this->getData("permalink");
203 203
         $parentTitle = $this->getData("page_title");
204 204
         $this->addActionButton($label,function($row) use ($label, $controllerName, $foreignKey, $additionalInfo, $parentPath, $parentTitle) {
205
-           $actionParameters = [
206
-               "label"=>$label,
207
-               "foreignKey"=>$foreignKey,
208
-               "foreignValue"=>$row->primary_key,
209
-               "parentPath"=>$parentPath,
210
-               "parentTitle"=>$parentTitle
211
-           ];
205
+            $actionParameters = [
206
+                "label"=>$label,
207
+                "foreignKey"=>$foreignKey,
208
+                "foreignValue"=>$row->primary_key,
209
+                "parentPath"=>$parentPath,
210
+                "parentTitle"=>$parentTitle
211
+            ];
212 212
 
213 213
             if(isset($additionalInfo) && is_callable($additionalInfo)) {
214 214
                 $additionalInfo = call_user_func($additionalInfo, $row);
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
217 217
                 }
218 218
             }
219 219
 
220
-           $actionHash = md5(serialize($actionParameters));
221
-           $actionHashToken = Cache::get("subModule".$actionHash);
222
-           if(!$actionHashToken) {
223
-               $actionHashToken = Str::random(5);
224
-               Cache::forever("subModule".$actionHash, $actionHashToken);
225
-               Cache::forever("subModule".$actionHashToken, $actionParameters);
226
-           }
220
+            $actionHash = md5(serialize($actionParameters));
221
+            $actionHashToken = Cache::get("subModule".$actionHash);
222
+            if(!$actionHashToken) {
223
+                $actionHashToken = Str::random(5);
224
+                Cache::forever("subModule".$actionHash, $actionHashToken);
225
+                Cache::forever("subModule".$actionHashToken, $actionParameters);
226
+            }
227 227
 
228
-           return action(class_basename($controllerName)."@getSubModule",['subModuleKey'=>$actionHashToken])."?ref=".makeReferalUrl($parentTitle);
228
+            return action(class_basename($controllerName)."@getSubModule",['subModuleKey'=>$actionHashToken])."?ref=".makeReferalUrl($parentTitle);
229 229
         }, $condition, $font, $color);
230 230
 
231 231
     }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
         $this->setButtonDetail(true);
34 34
         $this->setButtonSave(true);
35 35
         $this->setButtonLimitPage(true);
36
-        $this->hideButtonDeleteWhen(function ($row) { return false; });
37
-        $this->hideButtonDetailWhen(function ($row) { return false; });
38
-        $this->hideButtonEditWhen(function ($row) { return false; });
39
-        $this->style(function () { return null; });
40
-        $this->javascript(function () { return null; });
36
+        $this->hideButtonDeleteWhen(function($row) { return false; });
37
+        $this->hideButtonDetailWhen(function($row) { return false; });
38
+        $this->hideButtonEditWhen(function($row) { return false; });
39
+        $this->style(function() { return null; });
40
+        $this->javascript(function() { return null; });
41 41
     }
42 42
 
43 43
     public function appendAddForm(callable $html) {
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
      * @param ButtonColor $color
158 158
      * @param string $attributes
159 159
      */
160
-    public function addIndexActionButton($label, $actionURL, $fontAwesome_icon=null, $color=null, $attributes = null)
160
+    public function addIndexActionButton($label, $actionURL, $fontAwesome_icon = null, $color = null, $attributes = null)
161 161
     {
162
-        $color = ($color)?:ButtonColor::DARK_BLUE;
162
+        $color = ($color) ?: ButtonColor::DARK_BLUE;
163 163
 
164 164
         $model = new IndexActionButtonModel();
165 165
         $model->setLabel($label);
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
     public function addSubModule($label, $controllerName, $foreignKey, callable $additionalInfo = null, callable $condition = null, $font = null, $color = null) {
219 219
         $parentPath = $this->getData("permalink");
220 220
         $parentTitle = $this->getData("page_title");
221
-        $this->addActionButton($label,function($row) use ($label, $controllerName, $foreignKey, $additionalInfo, $parentPath, $parentTitle) {
221
+        $this->addActionButton($label, function($row) use ($label, $controllerName, $foreignKey, $additionalInfo, $parentPath, $parentTitle) {
222 222
            $actionParameters = [
223 223
                "label"=>$label,
224 224
                "foreignKey"=>$foreignKey,
@@ -227,22 +227,22 @@  discard block
 block discarded – undo
227 227
                "parentTitle"=>$parentTitle
228 228
            ];
229 229
 
230
-            if(isset($additionalInfo) && is_callable($additionalInfo)) {
230
+            if (isset($additionalInfo) && is_callable($additionalInfo)) {
231 231
                 $additionalInfo = call_user_func($additionalInfo, $row);
232
-                if(is_array($additionalInfo)) {
232
+                if (is_array($additionalInfo)) {
233 233
                     $actionParameters['info'] = $additionalInfo;
234 234
                 }
235 235
             }
236 236
 
237 237
            $actionHash = md5(serialize($actionParameters));
238 238
            $actionHashToken = Cache::get("subModule".$actionHash);
239
-           if(!$actionHashToken) {
239
+           if (!$actionHashToken) {
240 240
                $actionHashToken = Str::random(5);
241 241
                Cache::forever("subModule".$actionHash, $actionHashToken);
242 242
                Cache::forever("subModule".$actionHashToken, $actionParameters);
243 243
            }
244 244
 
245
-           return action(class_basename($controllerName)."@getSubModule",['subModuleKey'=>$actionHashToken])."?ref=".makeReferalUrl($parentTitle);
245
+           return action(class_basename($controllerName)."@getSubModule", ['subModuleKey'=>$actionHashToken])."?ref=".makeReferalUrl($parentTitle);
246 246
         }, $condition, $font, $color);
247 247
 
248 248
     }
@@ -255,12 +255,12 @@  discard block
 block discarded – undo
255 255
      * @param $fontAwesome_icon
256 256
      * @param ButtonColor|string $color
257 257
      */
258
-    public function addActionButton($label, $url_target, $condition_callback=null, $fontAwesome_icon=null, $color=null, $confirmation = false)
258
+    public function addActionButton($label, $url_target, $condition_callback = null, $fontAwesome_icon = null, $color = null, $confirmation = false)
259 259
     {
260 260
         $new = new AddActionButtonModel();
261 261
         $new->setLabel($label);
262
-        $new->setIcon($fontAwesome_icon?:"fa fa-bars");
263
-        $new->setColor($color?:"primary");
262
+        $new->setIcon($fontAwesome_icon ?: "fa fa-bars");
263
+        $new->setColor($color ?: "primary");
264 264
         $new->setUrl($url_target);
265 265
         $new->setCondition($condition_callback);
266 266
         $new->setConfirmation($confirmation);
Please login to merge, or discard this patch.
src/controllers/traits/Validation.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@
 block discarded – undo
19 19
      */
20 20
     private function validation()
21 21
     {
22
-        if(isset($this->data['validation'])) {
22
+        if (isset($this->data['validation'])) {
23 23
             $validator = Validator::make(request()->all(), @$this->data['validation'], @$this->data['validation_messages']);
24 24
             if ($validator->fails()) {
25 25
                 $message = $validator->messages();
26 26
                 $message_all = $message->all();
27
-                throw new CBValidationException(implode(', ',$message_all));
27
+                throw new CBValidationException(implode(', ', $message_all));
28 28
             }
29 29
         }
30 30
     }
Please login to merge, or discard this patch.
src/helpers/MiscellanousSingleton.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
 
24 24
     public function hasData($key) {
25 25
         $data = $this->data;
26
-        if(isset($data[$key])) return true;
26
+        if (isset($data[$key])) return true;
27 27
         else return false;
28 28
     }
29 29
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,11 @@
 block discarded – undo
23 23
 
24 24
     public function hasData($key) {
25 25
         $data = $this->data;
26
-        if(isset($data[$key])) return true;
27
-        else return false;
26
+        if(isset($data[$key])) {
27
+            return true;
28
+        } else {
29
+            return false;
30
+        }
28 31
     }
29 32
 
30 33
     public function setData($key, $value): void
Please login to merge, or discard this patch.