Passed
Push — master ( 66dd56...e66595 )
by Ferry
03:49
created
src/helpers/CB.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 {
19 19
 
20 20
     public function getRoleByName($roleName) {
21
-        return $this->find("cb_roles",['name'=>$roleName]);
21
+        return $this->find("cb_roles", ['name'=>$roleName]);
22 22
     }
23 23
 
24 24
     public function fcm() {
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     }
35 35
 
36 36
     public function getDeveloperUrl($path = null) {
37
-        $path = ($path)?"/".trim($path,"/"):null;
37
+        $path = ($path) ? "/".trim($path, "/") : null;
38 38
         return url(cbConfig("DEV_PATH")).$path;
39 39
     }
40 40
 
@@ -51,22 +51,22 @@  discard block
 block discarded – undo
51 51
     }
52 52
 
53 53
     public function getAdminUrl($path = null) {
54
-        $path = ($path)?"/".trim($path,"/"):null;
54
+        $path = ($path) ? "/".trim($path, "/") : null;
55 55
         return url(cbConfig("ADMIN_PATH")).$path;
56 56
     }
57 57
 
58 58
     public function getAppName() {
59
-        return env("APP_NAME","CRUDBOOSTER");
59
+        return env("APP_NAME", "CRUDBOOSTER");
60 60
     }
61 61
 
62 62
     public function uploadBase64($value)
63 63
     {
64 64
         $fileData = base64_decode($value);
65 65
         $mime_type = finfo_buffer(finfo_open(), $fileData, FILEINFO_MIME_TYPE);
66
-        if($mime_type) {
67
-            if($mime_type = explode('/', $mime_type)) {
66
+        if ($mime_type) {
67
+            if ($mime_type = explode('/', $mime_type)) {
68 68
                 $ext = $mime_type[1];
69
-                if($ext) {
69
+                if ($ext) {
70 70
                     $filePath = 'uploads/'.date('Y-m');
71 71
                     Storage::makeDirectory($filePath);
72 72
                     $filename = sha1(strRandom(5)).'.'.$ext;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
             $file = request()->file($name);
88 88
             $ext = $file->getClientOriginalExtension();
89
-            if(in_array($ext,cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) {
89
+            if (in_array($ext, cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) {
90 90
                 $filename = slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME));
91 91
                 $file_path = 'uploads/'.date('Y-m');
92 92
 
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
                 }
101 101
 
102 102
                 if (Storage::putFileAs($file_path, $file, $filename)) {
103
-                    if($resize_width || $resize_height) {
103
+                    if ($resize_width || $resize_height) {
104 104
                         $this->resizeImage($file_path.'/'.$filename, $resize_width, $resize_height);
105 105
                     }
106 106
                     return $file_path.'/'.$filename;
107 107
                 } else {
108 108
                     throw new \Exception("Something went wrong, file can't upload!");
109 109
                 }
110
-            }else{
110
+            } else {
111 111
                 throw new \Exception("The file format is not allowed!");
112 112
             }
113 113
 
@@ -130,22 +130,22 @@  discard block
 block discarded – undo
130 130
                 $img = Image::make(storage_path('app/'.$file_path.'/'.$filename));
131 131
                 $img->fit($resize_width, $resize_height);
132 132
                 $img->save(storage_path('app/'.$file_path.'/'.$filename), $qty);
133
-            } elseif ($resize_width && ! $resize_height) {
133
+            } elseif ($resize_width && !$resize_height) {
134 134
                 $img = Image::make(storage_path('app/'.$file_path.'/'.$filename));
135
-                $img->resize($resize_width, null, function ($constraint) {
135
+                $img->resize($resize_width, null, function($constraint) {
136 136
                     $constraint->aspectRatio();
137 137
                 });
138 138
                 $img->save(storage_path('app/'.$file_path.'/'.$filename), $qty);
139
-            } elseif (! $resize_width && $resize_height) {
139
+            } elseif (!$resize_width && $resize_height) {
140 140
                 $img = Image::make(storage_path('app/'.$file_path.'/'.$filename));
141
-                $img->resize(null, $resize_height, function ($constraint) {
141
+                $img->resize(null, $resize_height, function($constraint) {
142 142
                     $constraint->aspectRatio();
143 143
                 });
144 144
                 $img->save(storage_path('app/'.$file_path.'/'.$filename), $qty);
145 145
             } else {
146 146
                 $img = Image::make(storage_path('app/'.$file_path.'/'.$filename));
147 147
                 if ($img->width() > 1300) {
148
-                    $img->resize(1300, null, function ($constraint) {
148
+                    $img->resize(1300, null, function($constraint) {
149 149
                         $constraint->aspectRatio();
150 150
                     });
151 151
                 }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         $validator = Validator::make($input_arr, $rules, $messages);
253 253
         if ($validator->fails()) {
254 254
             $message = $validator->errors()->all();
255
-            throw new CBValidationException(implode("; ",$message));
255
+            throw new CBValidationException(implode("; ", $message));
256 256
         }
257 257
     }
258 258
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
     public function findPrimaryKey($table)
265 265
     {
266 266
         $pk = DB::getDoctrineSchemaManager()->listTableDetails($table)->getPrimaryKey();
267
-        if(!$pk) {
267
+        if (!$pk) {
268 268
             return null;
269 269
         }
270 270
         return $pk->getColumns()[0];
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
             $string_parameters_array = explode('&', $string_parameters);
314 314
             foreach ($string_parameters_array as $s) {
315 315
                 $part = explode('=', $s);
316
-                if(isset($part[0]) && isset($part[1])) {
316
+                if (isset($part[0]) && isset($part[1])) {
317 317
                     $name = htmlspecialchars(urldecode($part[0]));
318 318
                     $name = strip_tags($name);
319 319
                     $value = htmlspecialchars(urldecode($part[1]));
@@ -330,16 +330,16 @@  discard block
 block discarded – undo
330 330
 
331 331
 
332 332
     public function routeGet($prefix, $controller) {
333
-        $alias = str_replace("@"," ", $controller);
333
+        $alias = str_replace("@", " ", $controller);
334 334
         $alias = ucwords($alias);
335
-        $alias = str_replace(" ","",$alias);
335
+        $alias = str_replace(" ", "", $alias);
336 336
         Route::get($prefix, ['uses' => $controller, 'as' => $alias]);
337 337
     }
338 338
 
339 339
     public function routePost($prefix, $controller) {
340
-        $alias = str_replace("@"," ", $controller);
340
+        $alias = str_replace("@", " ", $controller);
341 341
         $alias = ucwords($alias);
342
-        $alias = str_replace(" ","",$alias);
342
+        $alias = str_replace(" ", "", $alias);
343 343
         Route::post($prefix, ['uses' => $controller, 'as' => $alias]);
344 344
     }
345 345
 
Please login to merge, or discard this patch.
src/types/checkbox/Checkbox.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public function optionsFromTable($table, $key_field, $display_field, $SQLCondition = null) {
36 36
         $data = DB::table($table);
37
-        if($SQLCondition && is_callable($SQLCondition)) {
37
+        if ($SQLCondition && is_callable($SQLCondition)) {
38 38
             $data = call_user_func($SQLCondition, $data);
39 39
         }elseif ($SQLCondition && is_string($SQLCondition)) {
40 40
             $data->whereRaw($SQLCondition);
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         $data = $data->get();
43 43
         $options = [];
44 44
         foreach ($data as $d) {
45
-            $options[ $d->$key_field ] = $d->$display_field;
45
+            $options[$d->$key_field] = $d->$display_field;
46 46
         }
47 47
         $this->options($options);
48 48
     }
Please login to merge, or discard this patch.
src/types/date/Hook.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@
 block discarded – undo
20 20
      */
21 21
     public function indexRender($row, $column)
22 22
     {
23
-        if($column->getFormat()) {
23
+        if ($column->getFormat()) {
24 24
             return date($column->getFormat(), strtotime($row->{$column->getField()}));
25
-        }else{
25
+        } else {
26 26
             return $row->{$column->getField()};
27 27
         }
28 28
     }
Please login to merge, or discard this patch.
src/helpers/UserSession.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php 
2 2
 namespace crocodicstudio\crudbooster\helpers;
3 3
 
4
-class UserSession  {
4
+class UserSession {
5 5
 
6 6
     public function user()
7 7
     {
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
     public function photo()
22 22
     {
23 23
         $user = $this->user();
24
-        return ($user->photo)?asset($user->photo):asset(dummyPhoto());
24
+        return ($user->photo) ?asset($user->photo) : asset(dummyPhoto());
25 25
     }
26 26
 
27 27
     public function roleName()
28 28
     {
29 29
         $user = $this->user();
30 30
         $role = cb()->find("cb_roles", $user->cb_roles_id);
31
-        if($role) return $role->name;
31
+        if ($role) return $role->name;
32 32
         else return null;
33 33
     }
34 34
 
Please login to merge, or discard this patch.
src/controllers/AdminProfileController.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
     public function getIndex() {
12 12
         $data = [];
13 13
         $data['page_title'] = 'Profile';
14
-        return view('crudbooster::profile',$data);
14
+        return view('crudbooster::profile', $data);
15 15
     }
16 16
 
17 17
     public function postUpdate() {
18
-        validator(request()->all(),[
18
+        validator(request()->all(), [
19 19
             'name'=>'required|max:255|min:3',
20 20
             'email'=>'required|email',
21 21
             'photo'=>'image',
@@ -26,19 +26,19 @@  discard block
 block discarded – undo
26 26
             $data = [];
27 27
             $data['name'] = request('name');
28 28
             $data['email'] = request('email');
29
-            if(request('password')) {
29
+            if (request('password')) {
30 30
                 $data['password'] = Hash::make(request('password'));
31 31
             }
32
-            if(request()->hasFile('photo')) {
32
+            if (request()->hasFile('photo')) {
33 33
                 $data['photo'] = cb()->uploadFile('photo', true, 200, 200);
34 34
             }
35 35
             DB::table("users")->where("id", auth()->id())->update($data);
36
-        }catch (\Exception $e) {
36
+        } catch (\Exception $e) {
37 37
             Log::error($e);
38
-            return cb()->redirectBack("Something went wrong!","warning");
38
+            return cb()->redirectBack("Something went wrong!", "warning");
39 39
         }
40 40
 
41
-        return cb()->redirectBack("The profile data has been updated!","success");
41
+        return cb()->redirectBack("The profile data has been updated!", "success");
42 42
     }
43 43
 
44 44
 }
Please login to merge, or discard this patch.
src/helpers/SidebarMenus.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     private function assignToModel($menu) {
23 23
         $model = new SidebarModel();
24 24
         $model->setId($menu->id);
25
-        if($menu->type == "url") {
25
+        if ($menu->type == "url") {
26 26
             $model->setUrl($menu->path);
27 27
             $model->setIcon($menu->icon);
28 28
             $model->setName($menu->name);
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
             $model->setBasepath(config('crudbooster.ADMIN_PATH').'/'.basename($model->getUrl()));
44 44
         }
45 45
 
46
-        if(request()->is($model->getBasepath()."*")) {
46
+        if (request()->is($model->getBasepath()."*")) {
47 47
             $model->setIsActive(true);
48
-        }else{
48
+        } else {
49 49
             $model->setIsActive(false);
50 50
         }
51 51
 
@@ -54,22 +54,22 @@  discard block
 block discarded – undo
54 54
 
55 55
     private function loadData($parent_id = null) {
56 56
         $menus = DB::table("cb_menus");
57
-        if($parent_id) {
58
-            $menus->where("parent_cb_menus_id",$parent_id);
59
-        }else{
57
+        if ($parent_id) {
58
+            $menus->where("parent_cb_menus_id", $parent_id);
59
+        } else {
60 60
             $menus->whereNull("parent_cb_menus_id");
61 61
         }
62
-        return $menus->orderBy("sort_number","asc")->get();
62
+        return $menus->orderBy("sort_number", "asc")->get();
63 63
     }
64 64
 
65 65
     private function rolePrivilege($cb_roles_id, $cb_menus_id) {
66
-        return cb()->find("cb_role_privileges",['cb_roles_id'=>$cb_roles_id,'cb_menus_id'=>$cb_menus_id]);
66
+        return cb()->find("cb_role_privileges", ['cb_roles_id'=>$cb_roles_id, 'cb_menus_id'=>$cb_menus_id]);
67 67
     }
68 68
 
69
-    private function checkPrivilege($roles_id,$menu) {
70
-        if($roles_id) {
69
+    private function checkPrivilege($roles_id, $menu) {
70
+        if ($roles_id) {
71 71
             $privilege = $this->rolePrivilege($roles_id, $menu->id);
72
-            if($privilege && !$privilege->can_browse) {
72
+            if ($privilege && !$privilege->can_browse) {
73 73
                 return false;
74 74
             }
75 75
         }
@@ -78,36 +78,36 @@  discard block
 block discarded – undo
78 78
     }
79 79
 
80 80
     public function all($withPrivilege = true) {
81
-        $roles_id = ($withPrivilege)?cb()->session()->roleId():null;
81
+        $roles_id = ($withPrivilege) ?cb()->session()->roleId() : null;
82 82
         $menus = $this->loadData();
83 83
         $result = [];
84 84
         $menus_active = false;
85
-        foreach($menus as $menu) {
85
+        foreach ($menus as $menu) {
86 86
 
87
-            if($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) continue;
87
+            if ($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) continue;
88 88
 
89 89
             $sidebarModel = $this->assignToModel($menu);
90
-            if($sidebarModel->getisActive()) $menus_active = true;
91
-            if($menus2 = $this->loadData($menu->id)) {
90
+            if ($sidebarModel->getisActive()) $menus_active = true;
91
+            if ($menus2 = $this->loadData($menu->id)) {
92 92
                 $sub1 = [];
93 93
                 $menus2_active = false;
94 94
                 foreach ($menus2 as $menu2) {
95 95
 
96
-                    if($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) continue;
96
+                    if ($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) continue;
97 97
 
98 98
                     $sidebarModel2 = $this->assignToModel($menu2);
99
-                    if($sidebarModel2->getisActive()) $menus2_active = true;
99
+                    if ($sidebarModel2->getisActive()) $menus2_active = true;
100 100
 
101
-                    if($menus3 = $this->loadData($menu2->id)) {
101
+                    if ($menus3 = $this->loadData($menu2->id)) {
102 102
                         $sub2 = [];
103 103
                         $menus3_active = false;
104 104
                         foreach ($menus3 as $menu3) {
105 105
 
106
-                            if($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) continue;
106
+                            if ($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) continue;
107 107
 
108 108
                             $sidebarModel3 = $this->assignToModel($menu3);
109 109
 
110
-                            if($sidebarModel3->getisActive()) {
110
+                            if ($sidebarModel3->getisActive()) {
111 111
                                 $menus3_active = true;
112 112
                             }
113 113
 
Please login to merge, or discard this patch.
src/controllers/traits/ControllerSetting.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
         $this->setButtonDetail(true);
30 30
         $this->setButtonSave(true);
31 31
         $this->setButtonLimitPage(true);
32
-        $this->hideButtonDeleteWhen(function ($row) { return false; });
33
-        $this->hideButtonDetailWhen(function ($row) { return false; });
34
-        $this->hideButtonEditWhen(function ($row) { return false; });
32
+        $this->hideButtonDeleteWhen(function($row) { return false; });
33
+        $this->hideButtonDetailWhen(function($row) { return false; });
34
+        $this->hideButtonEditWhen(function($row) { return false; });
35 35
     }
36 36
 
37 37
 
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
      * @param ButtonColor $color
129 129
      * @param string $attributes
130 130
      */
131
-    public function addIndexActionButton($label, $actionURL, $fontAwesome_icon=null, $color=null, $attributes = null)
131
+    public function addIndexActionButton($label, $actionURL, $fontAwesome_icon = null, $color = null, $attributes = null)
132 132
     {
133
-        $color = ($color)?:ButtonColor::DARK_BLUE;
133
+        $color = ($color) ?: ButtonColor::DARK_BLUE;
134 134
 
135 135
         $model = new IndexActionButtonModel();
136 136
         $model->setLabel($label);
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
      * @param $fontAwesome_icon
186 186
      * @param ButtonColor|string $color
187 187
      */
188
-    public function addActionButton($label, $url_target, $condition_callback=null, $fontAwesome_icon=null, $color=null, $confirmation = false)
188
+    public function addActionButton($label, $url_target, $condition_callback = null, $fontAwesome_icon = null, $color = null, $confirmation = false)
189 189
     {
190 190
         $new = new AddActionButtonModel();
191 191
         $new->setLabel($label);
192
-        $new->setIcon($fontAwesome_icon?:"fa fa-bars");
193
-        $new->setColor($color?:"primary");
192
+        $new->setIcon($fontAwesome_icon ?: "fa fa-bars");
193
+        $new->setColor($color ?: "primary");
194 194
         $new->setUrl($url_target);
195 195
         $new->setCondition($condition_callback);
196 196
         $new->setConfirmation($confirmation);
Please login to merge, or discard this patch.
src/types/image/Hook.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     public function detailRender($row, $column)
29 29
     {
30 30
         $column->setValue($row->{ $column->getField() });
31
-        return view("types::image.detail",[
31
+        return view("types::image.detail", [
32 32
             'row'=>$row,
33 33
             'column'=>$column
34 34
         ]);
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     public function indexRender($row, $column)
38 38
     {
39 39
         $column->setValue($row->{ $column->getField() });
40
-        return view("types::image.index",[
40
+        return view("types::image.index", [
41 41
             'row'=>$row,
42 42
             'column'=>$column
43 43
         ]);
Please login to merge, or discard this patch.
src/types/file/Hook.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
     public function detailRender($row, $column)
28 28
     {
29 29
         $column->setValue($row->{ $column->getField() });
30
-        return view("types::file.detail",[
30
+        return view("types::file.detail", [
31 31
             'row'=>$row,
32 32
             'column'=>$column
33 33
         ]);
Please login to merge, or discard this patch.