Passed
Push — master ( b2403f...1badbf )
by Ferry
07:20 queued 02:39
created
src/helpers/Module.php 3 patches
Braces   +37 added lines, -22 removed lines patch added patch discarded remove patch
@@ -76,45 +76,60 @@  discard block
 block discarded – undo
76 76
 
77 77
     public function canBrowse() {
78 78
         if($this->privilege) {
79
-            if($this->privilege->can_browse) return true;
80
-            else return false;
81
-        }else{
79
+            if($this->privilege->can_browse) {
80
+                return true;
81
+            } else {
82
+                return false;
83
+            }
84
+        } else{
82 85
             return true;
83 86
         }
84 87
     }
85 88
 
86 89
     public function canCreate() {
87 90
         if($this->privilege) {
88
-            if($this->privilege->can_create) return true;
89
-            else return false;
90
-        }else{
91
+            if($this->privilege->can_create) {
92
+                return true;
93
+            } else {
94
+                return false;
95
+            }
96
+        } else{
91 97
             return true;
92 98
         }
93 99
     }
94 100
 
95 101
     public function canRead() {
96 102
         if($this->privilege) {
97
-            if($this->privilege->can_read) return true;
98
-            else return false;
99
-        }else{
103
+            if($this->privilege->can_read) {
104
+                return true;
105
+            } else {
106
+                return false;
107
+            }
108
+        } else{
100 109
             return true;
101 110
         }
102 111
     }
103 112
 
104 113
     public function canUpdate() {
105 114
         if($this->privilege) {
106
-            if($this->privilege->can_update) return true;
107
-            else return false;
108
-        }else{
115
+            if($this->privilege->can_update) {
116
+                return true;
117
+            } else {
118
+                return false;
119
+            }
120
+        } else{
109 121
             return true;
110 122
         }
111 123
     }
112 124
 
113 125
     public function canDelete() {
114 126
         if($this->privilege) {
115
-            if($this->privilege->can_delete) return true;
116
-            else return false;
117
-        }else{
127
+            if($this->privilege->can_delete) {
128
+                return true;
129
+            } else {
130
+                return false;
131
+            }
132
+        } else{
118 133
             return true;
119 134
         }
120 135
     }
@@ -123,7 +138,7 @@  discard block
 block discarded – undo
123 138
     {
124 139
         if($this->controller_class && method_exists($this->controller_class, 'getAdd')) {
125 140
             return action($this->controller.'@getAdd');
126
-        }else{
141
+        } else{
127 142
             return null;
128 143
         }
129 144
     }
@@ -132,7 +147,7 @@  discard block
 block discarded – undo
132 147
     {
133 148
         if($this->controller_class && method_exists($this->controller_class, 'postAddSave')) {
134 149
             return action($this->controller.'@postAddSave');
135
-        }else{
150
+        } else{
136 151
             return null;
137 152
         }
138 153
     }
@@ -141,7 +156,7 @@  discard block
 block discarded – undo
141 156
     {
142 157
         if($this->controller_class && method_exists($this->controller_class, 'getEdit')) {
143 158
             return action($this->controller.'@getEdit',['id'=>$id]);
144
-        }else{
159
+        } else{
145 160
             return null;
146 161
         }
147 162
     }
@@ -150,7 +165,7 @@  discard block
 block discarded – undo
150 165
     {
151 166
         if(method_exists($this->controller_class, 'postEditSave')) {
152 167
             return action($this->controller.'@postEditSave',['id'=>$id]);
153
-        }else{
168
+        } else{
154 169
             return null;
155 170
         }
156 171
     }
@@ -159,7 +174,7 @@  discard block
 block discarded – undo
159 174
     {
160 175
         if($this->controller_class && method_exists($this->controller_class, 'getDetail')) {
161 176
             return action($this->controller.'@getDetail',['id'=>$id]);
162
-        }else{
177
+        } else{
163 178
             return null;
164 179
         }
165 180
     }
@@ -168,7 +183,7 @@  discard block
 block discarded – undo
168 183
     {
169 184
         if($this->controller_class && method_exists($this->controller_class, 'getDelete')) {
170 185
             return action($this->controller.'@getDelete',['id'=>$id]);
171
-        }else{
186
+        } else{
172 187
             return null;
173 188
         }
174 189
     }
@@ -177,7 +192,7 @@  discard block
 block discarded – undo
177 192
     {
178 193
         if($this->controller_class && method_exists($this->controller_class, 'getIndex')) {
179 194
             return trim(action($this->controller.'@getIndex').'/'.$path,'/');
180
-        }else{
195
+        } else{
181 196
             return null;
182 197
         }
183 198
     }
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@
 block discarded – undo
37 37
                     $this->menu = (!$this->menu)?cb()->find("cb_menus",["type"=>"path","path"=>request()->segment(2)]):$this->menu;
38 38
                     if($this->menu) {
39 39
                         $this->privilege = cb()->find("cb_role_privileges",[
40
-                           "cb_menus_id"=>$this->menu->id,
41
-                           "cb_roles_id"=>cb()->session()->roleId()
40
+                            "cb_menus_id"=>$this->menu->id,
41
+                            "cb_roles_id"=>cb()->session()->roleId()
42 42
                         ]);
43 43
                     }
44 44
                 }
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -26,17 +26,17 @@  discard block
 block discarded – undo
26 26
         try {
27 27
             $routeArray = request()->route()->getAction();
28 28
             $this->controller = class_basename($routeArray['controller']);
29
-            $this->controller = strtok($this->controller,"@");
29
+            $this->controller = strtok($this->controller, "@");
30 30
 
31 31
             $className = "\\".$routeArray["namespace"]."\\".$this->controller;
32
-            if(class_exists($className)) {
33
-                $this->module = cb()->find("cb_modules",["controller"=>$this->controller]);
34
-                if($this->module) {
32
+            if (class_exists($className)) {
33
+                $this->module = cb()->find("cb_modules", ["controller"=>$this->controller]);
34
+                if ($this->module) {
35 35
                     $this->controller_class = new $className();
36
-                    $this->menu = cb()->find("cb_menus",["cb_modules_id"=>$this->module->id]);
37
-                    $this->menu = (!$this->menu)?cb()->find("cb_menus",["type"=>"path","path"=>request()->segment(2)]):$this->menu;
38
-                    if($this->menu) {
39
-                        $this->privilege = cb()->find("cb_role_privileges",[
36
+                    $this->menu = cb()->find("cb_menus", ["cb_modules_id"=>$this->module->id]);
37
+                    $this->menu = (!$this->menu) ?cb()->find("cb_menus", ["type"=>"path", "path"=>request()->segment(2)]) : $this->menu;
38
+                    if ($this->menu) {
39
+                        $this->privilege = cb()->find("cb_role_privileges", [
40 40
                            "cb_menus_id"=>$this->menu->id,
41 41
                            "cb_roles_id"=>cb()->session()->roleId()
42 42
                         ]);
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
     }
58 58
 
59 59
     public function getData($key) {
60
-        if($this->controller_class) {
60
+        if ($this->controller_class) {
61 61
             $value = $this->controller_class->getData($key);
62
-            if(isset($value)) {
62
+            if (isset($value)) {
63 63
                 return $value;
64 64
             }
65 65
         }
@@ -70,128 +70,128 @@  discard block
 block discarded – undo
70 70
      * @return CBController
71 71
      */
72 72
     public function getController() {
73
-        return ($this->controller_class)?$this->controller_class:null;
73
+        return ($this->controller_class) ? $this->controller_class : null;
74 74
     }
75 75
 
76 76
     public function getPageTitle()
77 77
     {
78
-        return ($this->controller_class)?$this->controller_class->getData("page_title")?:cb()->getAppName():null;
78
+        return ($this->controller_class) ? $this->controller_class->getData("page_title") ?: cb()->getAppName() : null;
79 79
     }
80 80
 
81 81
     public function getTable()
82 82
     {
83
-        return ($this->controller_class)?$this->controller_class->getData("table"):null;
83
+        return ($this->controller_class) ? $this->controller_class->getData("table") : null;
84 84
     }
85 85
 
86 86
     public function getPageIcon()
87 87
     {
88
-        return ($this->controller_class)?$this->controller_class->getData('page_icon')?:"fa fa-bars":null;
88
+        return ($this->controller_class) ? $this->controller_class->getData('page_icon') ?: "fa fa-bars" : null;
89 89
     }
90 90
 
91 91
     public function canBrowse() {
92
-        if($this->privilege) {
93
-            if($this->privilege->can_browse) return true;
92
+        if ($this->privilege) {
93
+            if ($this->privilege->can_browse) return true;
94 94
             else return false;
95
-        }else{
95
+        } else {
96 96
             return true;
97 97
         }
98 98
     }
99 99
 
100 100
     public function canCreate() {
101
-        if($this->privilege) {
102
-            if($this->privilege->can_create) return true;
101
+        if ($this->privilege) {
102
+            if ($this->privilege->can_create) return true;
103 103
             else return false;
104
-        }else{
104
+        } else {
105 105
             return true;
106 106
         }
107 107
     }
108 108
 
109 109
     public function canRead() {
110
-        if($this->privilege) {
111
-            if($this->privilege->can_read) return true;
110
+        if ($this->privilege) {
111
+            if ($this->privilege->can_read) return true;
112 112
             else return false;
113
-        }else{
113
+        } else {
114 114
             return true;
115 115
         }
116 116
     }
117 117
 
118 118
     public function canUpdate() {
119
-        if($this->privilege) {
120
-            if($this->privilege->can_update) return true;
119
+        if ($this->privilege) {
120
+            if ($this->privilege->can_update) return true;
121 121
             else return false;
122
-        }else{
122
+        } else {
123 123
             return true;
124 124
         }
125 125
     }
126 126
 
127 127
     public function canDelete() {
128
-        if($this->privilege) {
129
-            if($this->privilege->can_delete) return true;
128
+        if ($this->privilege) {
129
+            if ($this->privilege->can_delete) return true;
130 130
             else return false;
131
-        }else{
131
+        } else {
132 132
             return true;
133 133
         }
134 134
     }
135 135
 
136 136
     public function addURL()
137 137
     {
138
-        if($this->controller_class && method_exists($this->controller_class, 'getAdd')) {
138
+        if ($this->controller_class && method_exists($this->controller_class, 'getAdd')) {
139 139
             return action($this->controller.'@getAdd');
140
-        }else{
140
+        } else {
141 141
             return null;
142 142
         }
143 143
     }
144 144
 
145 145
     public function addSaveURL()
146 146
     {
147
-        if($this->controller_class && method_exists($this->controller_class, 'postAddSave')) {
147
+        if ($this->controller_class && method_exists($this->controller_class, 'postAddSave')) {
148 148
             return action($this->controller.'@postAddSave');
149
-        }else{
149
+        } else {
150 150
             return null;
151 151
         }
152 152
     }
153 153
 
154 154
     public function editURL($id = null)
155 155
     {
156
-        if($this->controller_class && method_exists($this->controller_class, 'getEdit')) {
157
-            return action($this->controller.'@getEdit',['id'=>$id]);
158
-        }else{
156
+        if ($this->controller_class && method_exists($this->controller_class, 'getEdit')) {
157
+            return action($this->controller.'@getEdit', ['id'=>$id]);
158
+        } else {
159 159
             return null;
160 160
         }
161 161
     }
162 162
 
163 163
     public function editSaveURL($id = null)
164 164
     {
165
-        if(method_exists($this->controller_class, 'postEditSave')) {
166
-            return action($this->controller.'@postEditSave',['id'=>$id]);
167
-        }else{
165
+        if (method_exists($this->controller_class, 'postEditSave')) {
166
+            return action($this->controller.'@postEditSave', ['id'=>$id]);
167
+        } else {
168 168
             return null;
169 169
         }
170 170
     }
171 171
 
172
-    public function detailURL($id=null)
172
+    public function detailURL($id = null)
173 173
     {
174
-        if($this->controller_class && method_exists($this->controller_class, 'getDetail')) {
175
-            return action($this->controller.'@getDetail',['id'=>$id]);
176
-        }else{
174
+        if ($this->controller_class && method_exists($this->controller_class, 'getDetail')) {
175
+            return action($this->controller.'@getDetail', ['id'=>$id]);
176
+        } else {
177 177
             return null;
178 178
         }
179 179
     }
180 180
 
181
-    public function deleteURL($id=null)
181
+    public function deleteURL($id = null)
182 182
     {
183
-        if($this->controller_class && method_exists($this->controller_class, 'getDelete')) {
184
-            return action($this->controller.'@getDelete',['id'=>$id]);
185
-        }else{
183
+        if ($this->controller_class && method_exists($this->controller_class, 'getDelete')) {
184
+            return action($this->controller.'@getDelete', ['id'=>$id]);
185
+        } else {
186 186
             return null;
187 187
         }
188 188
     }
189 189
 
190 190
     public function url($path = null)
191 191
     {
192
-        if($this->controller_class && method_exists($this->controller_class, 'getIndex')) {
193
-            return trim(action($this->controller.'@getIndex').'/'.$path,'/');
194
-        }else{
192
+        if ($this->controller_class && method_exists($this->controller_class, 'getIndex')) {
193
+            return trim(action($this->controller.'@getIndex').'/'.$path, '/');
194
+        } else {
195 195
             return null;
196 196
         }
197 197
     }
Please login to merge, or discard this patch.
src/types/datetime/Hook.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
     {
23 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.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@  discard block
 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
     }
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     {
37 37
         $start = sanitizeXSS($value['start']);
38 38
         $end = sanitizeXSS($value['end']);
39
-        if($start && $end) {
39
+        if ($start && $end) {
40 40
             $start = date("Y-m-d H:i:s", strtotime($start));
41 41
             $end = date("Y-m-d H:i:s", strtotime($end));
42 42
             $query->whereBetween($column->getFilterColumn(), [$start, $end]);
Please login to merge, or discard this patch.
src/types/radio/Radio.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
         $data = DB::table($table);
37 37
         if($SQLCondition && is_callable($SQLCondition)) {
38 38
             $data = call_user_func($SQLCondition, $data);
39
-        }elseif ($SQLCondition && is_string($SQLCondition)) {
39
+        } elseif ($SQLCondition && is_string($SQLCondition)) {
40 40
             $data->whereRaw($SQLCondition);
41 41
         }
42 42
         $data = $data->get();
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function optionsFromTable($table, $key_field, $display_field, $SQLCondition = null) {
37 37
 
38
-        if(strpos($table,"App\Models")!==false) {
38
+        if (strpos($table, "App\Models") !== false) {
39 39
             $table = new $table();
40 40
             $table = $table::$tableName;
41 41
         }
42 42
 
43 43
         $data = DB::table($table);
44
-        if($SQLCondition && is_callable($SQLCondition)) {
44
+        if ($SQLCondition && is_callable($SQLCondition)) {
45 45
             $data = call_user_func($SQLCondition, $data);
46 46
         }elseif ($SQLCondition && is_string($SQLCondition)) {
47 47
             $data->whereRaw($SQLCondition);
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         $data = $data->get();
50 50
         $options = [];
51 51
         foreach ($data as $d) {
52
-            $options[ $d->$key_field ] = $d->$display_field;
52
+            $options[$d->$key_field] = $d->$display_field;
53 53
         }
54 54
         $this->options($options);
55 55
     }
Please login to merge, or discard this patch.
src/database/migrations/2016_08_07_152421_table_menus.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
      */
13 13
     public function up()
14 14
     {
15
-        Schema::create('cb_menus', function (Blueprint $table) {
15
+        Schema::create('cb_menus', function(Blueprint $table) {
16 16
             $table->increments("id");
17 17
             $table->string('name');
18 18
             $table->string("icon")->nullable();
Please login to merge, or discard this patch.
src/types/checkbox/Checkbox.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
         $data = DB::table($table);
37 37
         if($SQLCondition && is_callable($SQLCondition)) {
38 38
             $data = call_user_func($SQLCondition, $data);
39
-        }elseif ($SQLCondition && is_string($SQLCondition)) {
39
+        } elseif ($SQLCondition && is_string($SQLCondition)) {
40 40
             $data->whereRaw($SQLCondition);
41 41
         }
42 42
         $data = $data->get();
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
      * @param $SQLCondition string|callable
41 41
      */
42 42
     public function optionsFromTable($table, $key_field, $display_field, $SQLCondition = null) {
43
-        if(strpos($table,"App\Models")!==false) {
43
+        if (strpos($table, "App\Models") !== false) {
44 44
             $table = new $table();
45 45
             $table = $table::$tableName;
46 46
         }
47 47
 
48 48
         $data = DB::table($table);
49
-        if($SQLCondition && is_callable($SQLCondition)) {
49
+        if ($SQLCondition && is_callable($SQLCondition)) {
50 50
             $data = call_user_func($SQLCondition, $data);
51 51
         }elseif ($SQLCondition && is_string($SQLCondition)) {
52 52
             $data->whereRaw($SQLCondition);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         $data = $data->get();
55 55
         $options = [];
56 56
         foreach ($data as $d) {
57
-            $options[ $d->$key_field ] = $d->$display_field;
57
+            $options[$d->$key_field] = $d->$display_field;
58 58
         }
59 59
         $this->options($options);
60 60
     }
Please login to merge, or discard this patch.
src/types/date/Hook.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
     {
23 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.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,9 +19,9 @@  discard block
 block discarded – undo
19 19
      */
20 20
     public function indexRender($row, $column)
21 21
     {
22
-        if($column->getFormat()) {
22
+        if ($column->getFormat()) {
23 23
             return date($column->getFormat(), strtotime($row->{$column->getField()}));
24
-        }else{
24
+        } else {
25 25
             return $row->{$column->getField()};
26 26
         }
27 27
     }
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     {
36 36
         $start = sanitizeXSS($value['start']);
37 37
         $end = sanitizeXSS($value['end']);
38
-        if($start && $end) {
38
+        if ($start && $end) {
39 39
             $start = date("Y-m-d", strtotime($start));
40 40
             $end = date("Y-m-d", strtotime($end));
41 41
             $query->whereBetween($column->getFilterColumn(), [$start, $end]);
Please login to merge, or discard this patch.
src/helpers/UserSession.php 2 patches
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.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,8 +28,11 @@
 block discarded – undo
28 28
     {
29 29
         $user = $this->user();
30 30
         $role = cb()->find("cb_roles", $user->cb_roles_id);
31
-        if($role) return $role->name;
32
-        else return null;
31
+        if($role) {
32
+            return $role->name;
33
+        } else {
34
+            return null;
35
+        }
33 36
     }
34 37
 
35 38
     public function roleId()
Please login to merge, or discard this patch.
src/types/radio/component.blade.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
         <?php /** @var \crocodicstudio\crudbooster\types\radio\RadioModel $column */ ?>
3 3
         @foreach($column->getOptions() as $key=>$value)
4 4
             <?php
5
-                $columnValue = old($column->getName())?:($column->getDefaultValue())?:$column->getValue();
5
+                $columnValue = old($column->getName()) ?: ($column->getDefaultValue()) ?: $column->getValue();
6 6
             ?>
7 7
             <div class="{{ $column->getDisabled()?"disabled":"" }}">
8 8
                 <label class='radio-inline'>
Please login to merge, or discard this patch.
src/types/checkbox/Hook.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
      */
21 21
     public function assignment($value, $column)
22 22
     {
23
-        return @implode(";", request( $column->getName() ));
23
+        return @implode(";", request($column->getName()));
24 24
     }
25 25
 
26 26
 }
27 27
\ No newline at end of file
Please login to merge, or discard this patch.