Passed
Push — master ( a5af1f...b86701 )
by Ferry
03:55
created
src/middlewares/CBBackend.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@
 block discarded – undo
17 17
      */
18 18
     public function handle($request, Closure $next)
19 19
     {
20
-        if(auth()->guest()) {
21
-            return cb()->redirect(cb()->getLoginUrl("login"),trans('crudbooster.not_logged_in'),'warning');
20
+        if (auth()->guest()) {
21
+            return cb()->redirect(cb()->getLoginUrl("login"), trans('crudbooster.not_logged_in'), 'warning');
22 22
         }
23 23
 
24 24
         CBHook::beforeBackendMiddleware($request);
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/controllers/CBController.php 2 patches
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
 
28 28
     public function __call($method, $parameters)
29 29
     {
30
-        if($method == "getData") {
30
+        if ($method == "getData") {
31 31
             $key = $parameters[0];
32
-            if(isset($this->data[$key])) {
32
+            if (isset($this->data[$key])) {
33 33
                 return $this->data[$key];
34
-            }else{
34
+            } else {
35 35
                 return null;
36 36
             }
37
-        }else{
37
+        } else {
38 38
             return null;
39 39
         }
40 40
     }
@@ -49,19 +49,19 @@  discard block
 block discarded – undo
49 49
 
50 50
         $query->addSelect($this->data['table'].'.'.cb()->pk($this->data['table']).' as primary_key');
51 51
 
52
-        if(isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index']))
52
+        if (isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index']))
53 53
         {
54 54
             $query = call_user_func($this->data['hook_query_index'], $query);
55 55
         }
56 56
 
57
-        $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true;
58
-        if($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) {
57
+        $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true;
58
+        if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) {
59 59
             $query->whereNull($this->data['table'].'.deleted_at');
60 60
         }
61 61
 
62 62
 
63
-        if(isset($joins)) {
64
-            foreach($joins as $join)
63
+        if (isset($joins)) {
64
+            foreach ($joins as $join)
65 65
             {
66 66
                 $query->join($join['target_table'],
67 67
                         $join['target_table_primary'],
@@ -71,31 +71,31 @@  discard block
 block discarded – undo
71 71
             }
72 72
         }
73 73
 
74
-        foreach($columns as $column) {
74
+        foreach ($columns as $column) {
75 75
             /** @var ColumnModel $column */
76
-            if(strpos($column->getField(),".") === false) {
76
+            if (strpos($column->getField(), ".") === false) {
77 77
                 $query->addSelect($this->data['table'].'.'.$column->getField());
78
-            }else{
78
+            } else {
79 79
                 $query->addSelect($column->getField());
80 80
             }
81 81
 
82 82
             $query = getTypeHook($column->getType())->query($query, $column);
83 83
         }
84 84
 
85
-        if(request()->has('q'))
85
+        if (request()->has('q'))
86 86
         {
87
-            if(isset($this->data['hook_search_query'])) {
87
+            if (isset($this->data['hook_search_query'])) {
88 88
                 $query = call_user_func($this->data['hook_search_query'], $query);
89
-            }else{
90
-                $query->where(function ($where) use ($columns) {
89
+            } else {
90
+                $query->where(function($where) use ($columns) {
91 91
                     /**
92 92
                      * @var $where Builder
93 93
                      */
94
-                    foreach($columns as $column)
94
+                    foreach ($columns as $column)
95 95
                     {
96
-                        if(strpos($column->getField(),".") === false) {
96
+                        if (strpos($column->getField(), ".") === false) {
97 97
                             $field = $this->data['table'].'.'.$column->getField();
98
-                        }else{
98
+                        } else {
99 99
                             $field = $column->getField();
100 100
                         }
101 101
                         $where->orWhere($field, 'like', '%'.request('q').'%');
@@ -104,17 +104,17 @@  discard block
 block discarded – undo
104 104
             }
105 105
         }
106 106
 
107
-        if(isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) {
107
+        if (isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) {
108 108
             $query = call_user_func($this->data['hook_query_index'], $query);
109 109
         }
110 110
 
111 111
 
112
-        if(request()->has(['order_by','order_sort']))
112
+        if (request()->has(['order_by', 'order_sort']))
113 113
         {
114
-            if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) {
114
+            if (in_array(request('order_by'), columnSingleton()->getColumnNameOnly())) {
115 115
                 $query->orderBy(request('order_by'), request('order_sort'));
116 116
             }
117
-        }else{
117
+        } else {
118 118
             $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc");
119 119
         }
120 120
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 
124 124
     public function getIndex()
125 125
     {
126
-        if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
126
+        if (!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area");
127 127
 
128 128
         $query = $this->repository();
129 129
         $result = $query->paginate(20);
@@ -137,51 +137,51 @@  discard block
 block discarded – undo
137 137
      */
138 138
     private function validation()
139 139
     {
140
-        if(isset($this->data['validation'])) {
140
+        if (isset($this->data['validation'])) {
141 141
             $validator = Validator::make(request()->all(), @$this->data['validation'], @$this->data['validation_messages']);
142 142
             if ($validator->fails()) {
143 143
                 $message = $validator->messages();
144 144
                 $message_all = $message->all();
145
-                throw new CBValidationException(implode(', ',$message_all));
145
+                throw new CBValidationException(implode(', ', $message_all));
146 146
             }
147 147
         }
148 148
     }
149 149
 
150 150
     public function getAdd()
151 151
     {
152
-        if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
152
+        if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area");
153 153
 
154 154
         $data = [];
155 155
         $data['page_title'] = $this->data['page_title'].' : Add';
156 156
         $data['action_url'] = module()->addSaveURL();
157
-        return view('crudbooster::module.form.form',$data);
157
+        return view('crudbooster::module.form.form', $data);
158 158
     }
159 159
 
160 160
     public function postAddSave()
161 161
     {
162
-        if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
162
+        if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area");
163 163
 
164 164
         try {
165 165
             $this->validation();
166 166
             columnSingleton()->valueAssignment();
167 167
             $data = columnSingleton()->getAssignmentData();
168 168
 
169
-            if(Schema::hasColumn($this->data['table'], 'created_at')) {
169
+            if (Schema::hasColumn($this->data['table'], 'created_at')) {
170 170
                 $data['created_at'] = date('Y-m-d H:i:s');
171 171
             }
172 172
 
173 173
             $id = DB::table($this->data['table'])->insertGetId($data);
174 174
 
175
-            if(isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) {
175
+            if (isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) {
176 176
                 call_user_func($this->data['hook_after_insert'], $id);
177 177
             }
178 178
 
179 179
         } catch (CBValidationException $e) {
180 180
             Log::debug($e);
181
-            return cb()->redirectBack($e->getMessage(),'info');
181
+            return cb()->redirectBack($e->getMessage(), 'info');
182 182
         } catch (\Exception $e) {
183 183
             Log::error($e);
184
-            return cb()->redirectBack($e->getMessage(),'warning');
184
+            return cb()->redirectBack($e->getMessage(), 'warning');
185 185
         }
186 186
 
187 187
         if (request('submit') == trans('crudbooster.button_save_more')) {
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 
194 194
     public function getEdit($id)
195 195
     {
196
-        if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
196
+        if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area");
197 197
 
198 198
         $data = [];
199 199
         $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first();
@@ -204,17 +204,17 @@  discard block
 block discarded – undo
204 204
 
205 205
     public function postEditSave($id)
206 206
     {
207
-        if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
207
+        if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area");
208 208
 
209 209
         try {
210 210
             $this->validation();
211 211
             columnSingleton()->valueAssignment();
212 212
             $data = columnSingleton()->getAssignmentData();
213
-            if(Schema::hasColumn($this->data['table'], 'updated_at')) {
213
+            if (Schema::hasColumn($this->data['table'], 'updated_at')) {
214 214
                 $data['updated_at'] = date('Y-m-d H:i:s');
215 215
             }
216 216
 
217
-            if(isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) {
217
+            if (isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) {
218 218
                 call_user_func($this->data['hook_before_update'], $id);
219 219
             }
220 220
 
@@ -222,16 +222,16 @@  discard block
 block discarded – undo
222 222
                 ->where(cb()->pk($this->data['table']), $id)
223 223
                 ->update($data);
224 224
 
225
-            if(isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) {
225
+            if (isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) {
226 226
                 call_user_func($this->data['hook_after_update'], $id);
227 227
             }
228 228
 
229 229
         } catch (CBValidationException $e) {
230 230
             Log::debug($e);
231
-            return cb()->redirectBack($e->getMessage(),'info');
231
+            return cb()->redirectBack($e->getMessage(), 'info');
232 232
         } catch (\Exception $e) {
233 233
             Log::error($e);
234
-            return cb()->redirectBack($e->getMessage(),'warning');
234
+            return cb()->redirectBack($e->getMessage(), 'warning');
235 235
         }
236 236
 
237 237
 
@@ -244,15 +244,15 @@  discard block
 block discarded – undo
244 244
 
245 245
     public function getDelete($id)
246 246
     {
247
-        if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
247
+        if (!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area");
248 248
 
249
-        if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) {
249
+        if (isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) {
250 250
             call_user_func($this->data['hook_before_delete'], $id);
251 251
         }
252 252
 
253
-        $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true;
253
+        $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true;
254 254
 
255
-        if ($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) {
255
+        if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) {
256 256
             DB::table($this->data['table'])
257 257
                 ->where(getPrimaryKey($this->data['table']), $id)
258 258
                 ->update(['deleted_at' => date('Y-m-d H:i:s')]);
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
                 ->delete();
263 263
         }
264 264
 
265
-        if(isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) {
265
+        if (isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) {
266 266
             call_user_func($this->data['hook_after_delete'], $id);
267 267
         }
268 268
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 
272 272
     public function getDetail($id)
273 273
     {
274
-        if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
274
+        if (!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(), "You do not have access to this area");
275 275
 
276 276
         $data = [];
277 277
         $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first();
@@ -281,21 +281,21 @@  discard block
 block discarded – undo
281 281
 
282 282
     public function postUploadFile()
283 283
     {
284
-        if(auth()->guest()) return redirect(cb()->getLoginUrl());
284
+        if (auth()->guest()) return redirect(cb()->getLoginUrl());
285 285
 
286 286
         $file = null;
287 287
         try {
288 288
 
289 289
             cb()->validation([
290
-                'userfile' => 'required|mimes:' . config('crudbooster.UPLOAD_TYPES')
290
+                'userfile' => 'required|mimes:'.config('crudbooster.UPLOAD_TYPES')
291 291
             ]);
292 292
 
293 293
             $file = cb()->uploadFile('userfile', true);
294 294
 
295 295
         } catch (CBValidationException $e) {
296
-            return response()->json(['status'=>false,'message'=>$e->getMessage()]);
296
+            return response()->json(['status'=>false, 'message'=>$e->getMessage()]);
297 297
         } catch (\Exception $e) {
298
-            return response()->json(['status'=>false,'message'=>$e->getMessage()]);
298
+            return response()->json(['status'=>false, 'message'=>$e->getMessage()]);
299 299
         }
300 300
 
301 301
         return response()->json([
Please login to merge, or discard this patch.
Braces   +30 added lines, -14 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
             $key = $parameters[0];
32 32
             if(isset($this->data[$key])) {
33 33
                 return $this->data[$key];
34
-            }else{
34
+            } else{
35 35
                 return null;
36 36
             }
37
-        }else{
37
+        } else{
38 38
             return null;
39 39
         }
40 40
     }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             /** @var ColumnModel $column */
76 76
             if(strpos($column->getField(),".") === false) {
77 77
                 $query->addSelect($this->data['table'].'.'.$column->getField());
78
-            }else{
78
+            } else{
79 79
                 $query->addSelect($column->getField());
80 80
             }
81 81
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         {
87 87
             if(isset($this->data['hook_search_query'])) {
88 88
                 $query = call_user_func($this->data['hook_search_query'], $query);
89
-            }else{
89
+            } else{
90 90
                 $query->where(function ($where) use ($columns) {
91 91
                     /**
92 92
                      * @var $where Builder
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
                     {
96 96
                         if(strpos($column->getField(),".") === false) {
97 97
                             $field = $this->data['table'].'.'.$column->getField();
98
-                        }else{
98
+                        } else{
99 99
                             $field = $column->getField();
100 100
                         }
101 101
                         $where->orWhere($field, 'like', '%'.request('q').'%');
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) {
115 115
                 $query->orderBy(request('order_by'), request('order_sort'));
116 116
             }
117
-        }else{
117
+        } else{
118 118
             $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc");
119 119
         }
120 120
 
@@ -123,7 +123,9 @@  discard block
 block discarded – undo
123 123
 
124 124
     public function getIndex()
125 125
     {
126
-        if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
126
+        if(!module()->canBrowse()) {
127
+            return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
128
+        }
127 129
 
128 130
         $query = $this->repository();
129 131
         $result = $query->paginate(20);
@@ -149,7 +151,9 @@  discard block
 block discarded – undo
149 151
 
150 152
     public function getAdd()
151 153
     {
152
-        if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
154
+        if(!module()->canCreate()) {
155
+            return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
156
+        }
153 157
 
154 158
         $data = [];
155 159
         $data['page_title'] = $this->data['page_title'].' : Add';
@@ -159,7 +163,9 @@  discard block
 block discarded – undo
159 163
 
160 164
     public function postAddSave()
161 165
     {
162
-        if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
166
+        if(!module()->canCreate()) {
167
+            return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
168
+        }
163 169
 
164 170
         try {
165 171
             $this->validation();
@@ -193,7 +199,9 @@  discard block
 block discarded – undo
193 199
 
194 200
     public function getEdit($id)
195 201
     {
196
-        if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
202
+        if(!module()->canUpdate()) {
203
+            return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
204
+        }
197 205
 
198 206
         $data = [];
199 207
         $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first();
@@ -204,7 +212,9 @@  discard block
 block discarded – undo
204 212
 
205 213
     public function postEditSave($id)
206 214
     {
207
-        if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
215
+        if(!module()->canUpdate()) {
216
+            return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
217
+        }
208 218
 
209 219
         try {
210 220
             $this->validation();
@@ -244,7 +254,9 @@  discard block
 block discarded – undo
244 254
 
245 255
     public function getDelete($id)
246 256
     {
247
-        if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
257
+        if(!module()->canDelete()) {
258
+            return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
259
+        }
248 260
 
249 261
         if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) {
250 262
             call_user_func($this->data['hook_before_delete'], $id);
@@ -271,7 +283,9 @@  discard block
 block discarded – undo
271 283
 
272 284
     public function getDetail($id)
273 285
     {
274
-        if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
286
+        if(!module()->canRead()) {
287
+            return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area");
288
+        }
275 289
 
276 290
         $data = [];
277 291
         $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first();
@@ -281,7 +295,9 @@  discard block
 block discarded – undo
281 295
 
282 296
     public function postUploadFile()
283 297
     {
284
-        if(auth()->guest()) return redirect(cb()->getLoginUrl());
298
+        if(auth()->guest()) {
299
+            return redirect(cb()->getLoginUrl());
300
+        }
285 301
 
286 302
         $file = null;
287 303
         try {
Please login to merge, or discard this patch.
src/types/checkbox/Checkbox.php 2 patches
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.
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.
src/types/date/Hook.php 2 patches
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.
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.