Passed
Pull Request — master (#1276)
by Ferry
02:51
created
src/Modules/ApiGeneratorModule/ApiController/ExecuteApi.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
             }
61 61
             ApiResponder::send($result, $posts, $this->ctrl);
62 62
         } elseif (in_array($actionType, ['save_add', 'save_edit'])) {
63
-            $rowAssign = array_filter($input_validator, function ($column) use ($table) {
63
+            $rowAssign = array_filter($input_validator, function($column) use ($table) {
64 64
                 return Schema::hasColumn($table, $column);
65 65
             }, ARRAY_FILTER_USE_KEY);
66 66
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      */
114 114
     private function filterRows($data, $parameters, $posts, $table, $typeExcept)
115 115
     {
116
-        $data->where(function ($w) use ($parameters, $posts, $table, $typeExcept) {
116
+        $data->where(function($w) use ($parameters, $posts, $table, $typeExcept) {
117 117
             foreach ($parameters as $param) {
118 118
                 $name = $param['name'];
119 119
                 $type = $param['type'];
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      */
252 252
     private function applyLike($data, $search_in, $value)
253 253
     {
254
-        $data->where(function ($w) use ($search_in, $value) {
254
+        $data->where(function($w) use ($search_in, $value) {
255 255
             foreach ($search_in as $k => $field) {
256 256
                 $method = 'orWhere';
257 257
                 if ($k == 0) {
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
      */
273 273
     private function joinRelatedTables($table, $responsesFields, $name, $data, $nameTmp)
274 274
     {
275
-        if (! DbInspector::isForeignKey($name)) {
275
+        if (!DbInspector::isForeignKey($name)) {
276 276
             return $nameTmp;
277 277
         }
278 278
         $joinTable = DbInspector::getRelatedTableName($name);
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
     private function doValidation($inputValidator, $dataValidation, $posts)
298 298
     {
299 299
         $validator = Validator::make($inputValidator, $dataValidation);
300
-        if (! $validator->fails()) {
300
+        if (!$validator->fails()) {
301 301
             return true;
302 302
         }
303 303
         $message = $validator->errors()->all();
@@ -313,11 +313,11 @@  discard block
 block discarded – undo
313 313
      */
314 314
     private function filterRedundantResp($responses)
315 315
     {
316
-        $responses = array_filter($responses, function ($resp) {
317
-            return ! ($resp['name'] == 'ref_id' || $resp['type'] == 'custom');
316
+        $responses = array_filter($responses, function($resp) {
317
+            return !($resp['name'] == 'ref_id' || $resp['type'] == 'custom');
318 318
         });
319 319
 
320
-        $responses = array_filter($responses, function ($resp) {
320
+        $responses = array_filter($responses, function($resp) {
321 321
             return (intval($resp['used']) != 0 || DbInspector::isForeignKey($resp['name']));
322 322
         });
323 323
 
@@ -332,15 +332,15 @@  discard block
 block discarded – undo
332 332
     private function validateParams($parameters, $table)
333 333
     {
334 334
         $posts = request()->all();
335
-        if (! $parameters) {
335
+        if (!$parameters) {
336 336
             return ['', ''];
337 337
         }
338 338
         $typeExcept = ['password', 'ref', 'base64_file', 'custom', 'search'];
339 339
         $inputValidator = [];
340 340
         $dataValidation = [];
341 341
 
342
-        $parameters = array_filter($parameters, function ($param){
343
-            return !(is_string($param['config'])&& !starts_with($param['config'], '*'));
342
+        $parameters = array_filter($parameters, function($param) {
343
+            return !(is_string($param['config']) && !starts_with($param['config'], '*'));
344 344
         });
345 345
 
346 346
         foreach ($parameters as $param) {
Please login to merge, or discard this patch.
src/Modules/ApiGeneratorModule/ApiController/ApiValidations.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
     {
45 45
         $ctrl->hookValidate();
46 46
 
47
-        if (! $ctrl->validate) {
47
+        if (!$ctrl->validate) {
48 48
             return true;
49 49
         }  // hook have to return true
50 50
         //todo : translation
Please login to merge, or discard this patch.
src/CBCoreModule/Index.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -71,19 +71,19 @@  discard block
 block discarded – undo
71 71
             $data['result'] = $query->take($limit)->get();
72 72
             $totalData = count($data['result']);
73 73
             return $data;
74
-        }else{
74
+        } else {
75 75
             $data['result'] = $query->paginate($limit);
76 76
             $totalData = $data['result']->total();
77 77
         }
78 78
 
79 79
 
80 80
         $number = (request('page', 1) - 1) * $limit + 1;
81
-        $columnsTable = array_filter($columns, function ($col) {
81
+        $columnsTable = array_filter($columns, function($col) {
82 82
             return $col['visible'] ?? true;
83 83
         });
84 84
         $htmlContents = (new RowContent($CbCtrl))->calculate($data, $number, $columnsTable); //end foreach data[result]
85 85
 
86
-        $data['html_contents'] = ['html' => $htmlContents, 'data' => $data['result'],'total'=>$totalData];
86
+        $data['html_contents'] = ['html' => $htmlContents, 'data' => $data['result'], 'total'=>$totalData];
87 87
 
88 88
         return $data;
89 89
     }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
             $data['parent_field'] = DbInspector::getRelatedTableName($parent);
103 103
         }
104 104
 
105
-        if (! $data['parent_field']) {
105
+        if (!$data['parent_field']) {
106 106
             return $data;
107 107
         }
108 108
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      */
122 122
     private function _filterForParent($result)
123 123
     {
124
-        if (! request('parent_id')) {
124
+        if (!request('parent_id')) {
125 125
             return null;
126 126
         }
127 127
 
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
     private function _applyWhereAndQfilters($result, $columnsTable, $table)
193 193
     {
194 194
         if (request('q')) {
195
-            $result->where(function ($query) use ($columnsTable) {
195
+            $result->where(function($query) use ($columnsTable) {
196 196
                 foreach ($columnsTable as $col) {
197
-                    if (! $col['field_with']) {
197
+                    if (!$col['field_with']) {
198 198
                         continue;
199 199
                     }
200 200
                     $query->orwhere($col['field_with'], "like", "%".request("q")."%");
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@
 block discarded – undo
71 71
             $data['result'] = $query->take($limit)->get();
72 72
             $totalData = count($data['result']);
73 73
             return $data;
74
-        }else{
74
+        } else{
75 75
             $data['result'] = $query->paginate($limit);
76 76
             $totalData = $data['result']->total();
77 77
         }
Please login to merge, or discard this patch.
src/CBCoreModule/Installer/CbInstaller.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,11 +21,11 @@
 block discarded – undo
21 21
     public function createVendorAtPublic()
22 22
     {
23 23
         $this->console->info('Checking public/vendor directory...');
24
-        if (! file_exists(public_path('vendor'))) {
24
+        if (!file_exists(public_path('vendor'))) {
25 25
             mkdir(public_path('vendor'), 0777);
26 26
         }
27 27
 
28
-        if (! is_writable(public_path('vendor'))) {
28
+        if (!is_writable(public_path('vendor'))) {
29 29
             $this->console->info('Setup aborted !');
30 30
             $this->console->info('Please set public/vendor directory to writable 0777');
31 31
             exit;
Please login to merge, or discard this patch.
src/controllers/CBController/ExportData.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
     {
11 11
         $this->limit = request('limit');
12 12
         $this->indexReturn = true;
13
-        $filename = request('filename')?:'export';
13
+        $filename = request('filename') ?: 'export';
14 14
         $papersize = request('page_size');
15 15
         $paperorientation = request('page_orientation');        
16 16
         $indexContent = $this->getIndex();
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
             $this->table('cms_settings')->where('name', 'default_paper_size')->update(['content' => $papersize]);
20 20
         }
21 21
         $format = request('fileformat'); 
22
-        if(in_array($format, ['pdf', 'xls', 'csv']))
22
+        if (in_array($format, ['pdf', 'xls', 'csv']))
23 23
         {
24 24
             return app(IndexExport::class)->{$format}($filename, $indexContent, $paperorientation, $papersize);
25 25
         }
Please login to merge, or discard this patch.
src/controllers/CBController/Deleter.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
         $selectedIds = request('checkbox');
24 24
 
25 25
         $btnName = request('button_name');
26
-        if (! $selectedIds) {
26
+        if (!$selectedIds) {
27 27
             backWithMsg(cbTrans('at_least_one_row'), 'warning');
28 28
         }
29 29
         
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
         $message = cbTrans('alert_action', ['action' => $action]);
48 48
 
49 49
         if ($this->actionButtonSelected($id_selected, $button_name) === false) {
50
-            $message = ! empty($this->alert['message']) ? $this->alert['message'] : 'Error';
51
-            $type = ! empty($this->alert['type']) ? $this->alert['type'] : 'danger';
50
+            $message = !empty($this->alert['message']) ? $this->alert['message'] : 'Error';
51
+            $type = !empty($this->alert['type']) ? $this->alert['type'] : 'danger';
52 52
         }
53 53
 
54 54
         backWithMsg($message, $type);
Please login to merge, or discard this patch.
src/controllers/FileController.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
     
17 17
     public function uploadSummernote()
18 18
     {
19
-        echo asset(app( FileUploader::class)->uploadFile('userfile'));
19
+        echo asset(app(FileUploader::class)->uploadFile('userfile'));
20 20
     }
21 21
 
22 22
     public function uploadFile()
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
     {
29 29
         $import = app(IndexImport::class);
30 30
    
31
-        if (! Request::hasFile('userfile')) {
32
-            backWithMsg('Please select a file for first!','warning');
31
+        if (!Request::hasFile('userfile')) {
32
+            backWithMsg('Please select a file for first!', 'warning');
33 33
         }
34 34
         $file = Request::file('userfile');
35 35
         $validator = $import->validateForImport($file);
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         $fullStoragePath = storage_path('app/'.$fullFilePath);
52 52
 
53 53
 
54
-        if (! Storage::exists($fullFilePath)) {
54
+        if (!Storage::exists($fullFilePath)) {
55 55
             abort(404);
56 56
         }
57 57
         $hasImageExtension = $this->isImage($fullStoragePath);
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
     {
87 87
         $w = request('w', cbConfig('DEFAULT_THUMBNAIL_WIDTH', 300));
88 88
         $h = request('h', $w);
89
-        $imgRaw = Image::cache(function ($image) use ($fullStoragePath, $w, $h) {
89
+        $imgRaw = Image::cache(function($image) use ($fullStoragePath, $w, $h) {
90 90
             $im = $image->make($fullStoragePath);
91
-            if (! $w) {
91
+            if (!$w) {
92 92
                 return $im;
93 93
             }
94
-            if (! $h) {
94
+            if (!$h) {
95 95
                 $im->fit($w);
96 96
             } else {
97 97
                 $im->fit($w, $h);
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     {
112 112
         $extension = strtolower(File::extension($fullStoragePath));
113 113
 
114
-        return FieldDetector::isWithin($extension, 'IMAGE_EXTENSIONS');;
114
+        return FieldDetector::isWithin($extension, 'IMAGE_EXTENSIONS'); ;
115 115
     }
116 116
 
117 117
     /**
Please login to merge, or discard this patch.
src/controllers/CBController.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 
62 62
         $data = app(Index::class)->index($this);     
63 63
 
64
-        if($this->indexReturn) return $data;
64
+        if ($this->indexReturn) return $data;
65 65
 
66 66
         return $this->cbView('crudbooster::index.index', $data);
67 67
     }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     protected function genericLoader()
146 146
     {
147 147
         $this->cbInit();
148
-        $this->primaryKey = $this->primaryKey?: DbInspector::findPk($this->table);
148
+        $this->primaryKey = $this->primaryKey ?: DbInspector::findPk($this->table);
149 149
         $this->data_inputan = $this->form;
150 150
         $this->data['pk'] = $this->primaryKey;
151 151
         $this->data['hide_form'] = $this->hide_form;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,9 @@
 block discarded – undo
61 61
 
62 62
         $data = app(Index::class)->index($this);     
63 63
 
64
-        if($this->indexReturn) return $data;
64
+        if($this->indexReturn) {
65
+            return $data;
66
+        }
65 67
 
66 68
         return $this->cbView('crudbooster::index.index', $data);
67 69
     }
Please login to merge, or discard this patch.
src/helpers/cb_helpers.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -8,49 +8,49 @@  discard block
 block discarded – undo
8 8
 | ---------------------------------------------------------------------------------------------------------------
9 9
 |
10 10
 */
11
-if (! function_exists('cbModulesNS')) {
11
+if (!function_exists('cbModulesNS')) {
12 12
     function cbModulesNS(string $path = ''): string
13 13
     {
14 14
         return \Crocodicstudio\Crudbooster\Helpers\CbStructure::cbModulesNS($path);
15 15
     }
16 16
 }
17 17
 
18
-if (! function_exists('cbStartMarker')) {
18
+if (!function_exists('cbStartMarker')) {
19 19
     function cbStartMarker(string $section): string
20 20
     {
21 21
         return "# START $section DO NOT REMOVE THIS LINE";
22 22
     }
23 23
 }
24 24
 
25
-if (! function_exists('cbEndMarker')) {
25
+if (!function_exists('cbEndMarker')) {
26 26
     function cbEndMarker(string $section): string
27 27
     {
28 28
         return "# END $section DO NOT REMOVE THIS LINE";
29 29
     }
30 30
 }
31 31
 
32
-if (! function_exists('cbAdminPath')) {
32
+if (!function_exists('cbAdminPath')) {
33 33
     function cbAdminPath(): string
34 34
     {
35 35
         return cbConfig('ADMIN_PATH');
36 36
     }
37 37
 }
38 38
 
39
-if (! function_exists('ctrlNamespace')) {
39
+if (!function_exists('ctrlNamespace')) {
40 40
     function ctrlNamespace(): string
41 41
     {
42 42
         return \Crocodicstudio\Crudbooster\Helpers\CbStructure::ctrlNamespace();
43 43
     }
44 44
 }
45 45
 
46
-if (! function_exists('cbControllersNS')) {
46
+if (!function_exists('cbControllersNS')) {
47 47
     function cbControllersNS(): string
48 48
     {
49 49
         return \Crocodicstudio\Crudbooster\Helpers\CbStructure::cbControllersNS();
50 50
     }
51 51
 }
52 52
 
53
-if (! function_exists('is_checked')) {
53
+if (!function_exists('is_checked')) {
54 54
     /**
55 55
      * @param $format
56 56
      * @param $value
@@ -74,28 +74,28 @@  discard block
 block discarded – undo
74 74
     }
75 75
 }
76 76
 
77
-if (! function_exists('CbComponentsPath')) {
77
+if (!function_exists('CbComponentsPath')) {
78 78
     function CbComponentsPath(string $type = ''): string
79 79
     {
80 80
         return \Crocodicstudio\Crudbooster\Helpers\CbStructure::componentsPath($type);
81 81
     }
82 82
 }
83 83
 
84
-if (! function_exists('CbPublishedComponentsPath')) {
84
+if (!function_exists('CbPublishedComponentsPath')) {
85 85
     function CbPublishedComponentsPath(string $type = ''): string
86 86
     {
87 87
         return \Crocodicstudio\Crudbooster\Helpers\CbStructure::publishedComponentsPath($type);
88 88
     }
89 89
 }
90 90
 
91
-if (! function_exists('controllers_dir')) {
91
+if (!function_exists('controllers_dir')) {
92 92
     function controllers_dir(): string
93 93
     {
94 94
         return \Crocodicstudio\Crudbooster\Helpers\CbStructure::controllersDir();
95 95
     }
96 96
 }
97 97
 
98
-if (! function_exists('controller_path')) {
98
+if (!function_exists('controller_path')) {
99 99
     function controller_path(string $controller): string
100 100
     {
101 101
         return \Crocodicstudio\Crudbooster\Helpers\CbStructure::controllerPath($controller);
@@ -109,14 +109,14 @@  discard block
 block discarded – undo
109 109
 | $name = name of input
110 110
 |
111 111
 */
112
-if (! function_exists('g')) {
112
+if (!function_exists('g')) {
113 113
     function g($name)
114 114
     {
115 115
         return Request::get($name);
116 116
     }
117 117
 }
118 118
 
119
-if (! function_exists('cbTrans')) {
119
+if (!function_exists('cbTrans')) {
120 120
     /**
121 121
      * Translate the given message.
122 122
      *
@@ -130,44 +130,44 @@  discard block
 block discarded – undo
130 130
     }
131 131
 }
132 132
 
133
-if (! function_exists('cbAsset')) {
133
+if (!function_exists('cbAsset')) {
134 134
     function cbAsset($key)
135 135
     {
136 136
         return asset('vendor/crudbooster/assets/'.$key);
137 137
     }
138 138
 }
139 139
 
140
-if(! function_exists('cbAnchor')) {
141
-    function cbAnchor($url,$label,$attribute="") {        
140
+if (!function_exists('cbAnchor')) {
141
+    function cbAnchor($url, $label, $attribute = "") {        
142 142
         return "<a href='".$url."' ".$attribute." >".$label."</a>";
143 143
     }
144 144
 }
145 145
 
146
-if (! function_exists('cbScript')) {
146
+if (!function_exists('cbScript')) {
147 147
     function cbScript($key)
148 148
     {
149 149
         return '<script src="'.cbAsset($key).'" type="text/javascript"></script>';
150 150
     }
151 151
 }
152 152
 
153
-if (! function_exists('cbStyleSheet')) {
153
+if (!function_exists('cbStyleSheet')) {
154 154
     function cbStyleSheet($key)
155 155
     {
156 156
         return '<link rel="stylesheet" type="text/css" href="'.cbAsset($key).'"/>';
157 157
     }
158 158
 }
159 159
 
160
-if (! function_exists('cbConfig')) {
160
+if (!function_exists('cbConfig')) {
161 161
     function cbConfig($key, $default = null)
162 162
     {
163 163
         return config('crudbooster.'.$key, $default);
164 164
     }
165 165
 }
166
-if (! function_exists('makeValidationForHTML')) {
166
+if (!function_exists('makeValidationForHTML')) {
167 167
     function makeValidationForHTML($rules)
168 168
     {
169 169
         $validation = [];
170
-        $validation_raw = is_string($rules)? explode('|', $rules) : $rules;
170
+        $validation_raw = is_string($rules) ? explode('|', $rules) : $rules;
171 171
         foreach ($validation_raw as $vr) {
172 172
             $vr_a = explode(':', $vr);
173 173
             if (isset($vr_a[1])) {
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
     }
182 182
 }
183 183
 
184
-if (! function_exists('findSelected')) {
184
+if (!function_exists('findSelected')) {
185 185
     /**
186 186
      * @param $rawvalue
187 187
      * @param $form
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
      */
191 191
     function findSelected($rawvalue, $form, $optionValue)
192 192
     {
193
-        if (! $rawvalue) {
193
+        if (!$rawvalue) {
194 194
             return '';
195 195
         }
196 196
         $value = $rawvalue;
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         return $selected;
213 213
     }
214 214
 }
215
-if (! function_exists('array_get_keys')) {
215
+if (!function_exists('array_get_keys')) {
216 216
 
217 217
     /**
218 218
      * @param array $_array
@@ -228,21 +228,21 @@  discard block
 block discarded – undo
228 228
     }
229 229
 }
230 230
 
231
-if (! function_exists('cbGetSetting')) {
231
+if (!function_exists('cbGetSetting')) {
232 232
     function cbGetSetting($name)
233 233
     {
234 234
         return \Crocodicstudio\Crudbooster\Modules\SettingModule\SettingRepo::getSetting($name);
235 235
     }
236 236
 }
237 237
 
238
-if (! function_exists('backWithMsg')) {
238
+if (!function_exists('backWithMsg')) {
239 239
     function backWithMsg($msg, $type = 'success')
240 240
     {
241
-        respondWith(redirect()->back()->with(['message' => $msg, 'message_type' => $type,]));
241
+        respondWith(redirect()->back()->with(['message' => $msg, 'message_type' => $type, ]));
242 242
     }
243 243
 }
244 244
 
245
-if (! function_exists('underField')) {
245
+if (!function_exists('underField')) {
246 246
     function underField($help, $error)
247 247
     {
248 248
         $error = $error ? "<i class='fa fa-info-circle'></i> $error" : '';
@@ -250,21 +250,21 @@  discard block
 block discarded – undo
250 250
         return "<div class='text-danger'>$error</div><p class='help-block'>$help</p>";
251 251
     }
252 252
 }
253
-if (! function_exists('cbIcon')) {
253
+if (!function_exists('cbIcon')) {
254 254
     function cbIcon($icon)
255 255
     {
256 256
         return '<i class=\'fa fa-'.$icon.'\'></i>';
257 257
     }
258 258
 }
259 259
 
260
-if (! function_exists('YmdHis')) {
260
+if (!function_exists('YmdHis')) {
261 261
     function YmdHis()
262 262
     {
263 263
         return date('Y-m-d H:i:s');
264 264
     }
265 265
 }
266 266
 
267
-if (! function_exists('cbUser')) {
267
+if (!function_exists('cbUser')) {
268 268
     function cbUser()
269 269
     {
270 270
         return auth('cbAdmin')->user();
Please login to merge, or discard this patch.