Passed
Push — master ( 38a665...decd12 )
by Ferry
05:33
created
src/commands/Install.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
         if ($this->confirm('Do you have setting the database configuration at .env ?')) {
41 41
 
42
-            if (! file_exists(public_path('vendor')) ) {
42
+            if (!file_exists(public_path('vendor'))) {
43 43
                 mkdir(public_path('vendor'));
44 44
             }
45 45
 
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
              * We need it to change default laravel local filesystem from storage to public
55 55
              * We won't use symlink because of a security issue in many server
56 56
              */
57
-            if(!file_exists(public_path("storage"))) {
57
+            if (!file_exists(public_path("storage"))) {
58 58
                 $this->info("Create storage directory on /public");
59 59
                 mkdir(public_path("storage"));
60
-                file_put_contents(public_path("storage/.gitignore"),"!.gitignore");
61
-                file_put_contents(public_path("storage/index.html")," ");
60
+                file_put_contents(public_path("storage/.gitignore"), "!.gitignore");
61
+                file_put_contents(public_path("storage/index.html"), " ");
62 62
             }
63 63
 
64 64
             /*
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
              * Disable php execution on /vendor/*
68 68
              */
69 69
             $this->info("Tweak some security for your laravel");
70
-            file_put_contents(base_path(".htaccess"), "\n\n# Generated by CRUDBooster\nServerSignature Off\nIndexIgnore *\nRewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]\nRewriteRule ^vendor/.*\.(php|rb|py)$ - [F,L,NC]\n<FilesMatch \"^\.\">\nOrder allow,deny\nDeny from all\n</FilesMatch>",FILE_APPEND);
71
-            file_put_contents(public_path(".htaccess"), "\n\n# Generated by CRUDBooster\nServerSignature Off\nIndexIgnore *\nRewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]\nRewriteRule ^vendor/.*\.(php|rb|py)$ - [F,L,NC]\n<FilesMatch \"^\.\">\nOrder allow,deny\nDeny from all\n</FilesMatch>",FILE_APPEND);
70
+            file_put_contents(base_path(".htaccess"), "\n\n# Generated by CRUDBooster\nServerSignature Off\nIndexIgnore *\nRewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]\nRewriteRule ^vendor/.*\.(php|rb|py)$ - [F,L,NC]\n<FilesMatch \"^\.\">\nOrder allow,deny\nDeny from all\n</FilesMatch>", FILE_APPEND);
71
+            file_put_contents(public_path(".htaccess"), "\n\n# Generated by CRUDBooster\nServerSignature Off\nIndexIgnore *\nRewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]\nRewriteRule ^vendor/.*\.(php|rb|py)$ - [F,L,NC]\n<FilesMatch \"^\.\">\nOrder allow,deny\nDeny from all\n</FilesMatch>", FILE_APPEND);
72 72
 
73 73
 
74 74
             $this->info('Dumping the autoloaded files and reloading all new files...');
Please login to merge, or discard this patch.
src/CRUDBoosterServiceProvider.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
25 25
         // Register views
26 26
         $this->loadViewsFrom(__DIR__.'/views', 'crudbooster');
27 27
         $this->loadViewsFrom(__DIR__.'/types', 'types');
28
-        $this->loadTranslationsFrom(__DIR__."/localization","cb");
28
+        $this->loadTranslationsFrom(__DIR__."/localization", "cb");
29 29
 
30 30
         // Publish the files
31
-        $this->publishes([__DIR__.'/configs/crudbooster.php' => config_path('crudbooster.php')],'cb_config');
32
-        $this->publishes([__DIR__.'/database' => base_path('database')],'cb_migration');
33
-        $this->publishes([__DIR__.'/templates/CBHook.stub'=> app_path('Http/CBHook.php')],'cb_hook');
34
-        $this->publishes([__DIR__ . '/assets' =>public_path('cb_asset')],'cb_asset');
31
+        $this->publishes([__DIR__.'/configs/crudbooster.php' => config_path('crudbooster.php')], 'cb_config');
32
+        $this->publishes([__DIR__.'/database' => base_path('database')], 'cb_migration');
33
+        $this->publishes([__DIR__.'/templates/CBHook.stub'=> app_path('Http/CBHook.php')], 'cb_hook');
34
+        $this->publishes([__DIR__.'/assets' =>public_path('cb_asset')], 'cb_asset');
35 35
 
36 36
         // Override Local FileSystem
37 37
         Config::set("filesystems.disks.local.root", cbConfig("LOCAL_FILESYSTEM_PATH", public_path("storage")));
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
         require __DIR__.'/helpers/Helper.php';
53 53
 
54 54
         // Singletons
55
-        $this->app->singleton('crudbooster', function ()
55
+        $this->app->singleton('crudbooster', function()
56 56
         {
57 57
             return true;
58 58
         });
59 59
         $this->app->singleton('ColumnSingleton', ColumnSingleton::class);
60 60
 
61 61
         // Merging configuration
62
-        $this->mergeConfigFrom(__DIR__.'/configs/crudbooster.php','crudbooster');
62
+        $this->mergeConfigFrom(__DIR__.'/configs/crudbooster.php', 'crudbooster');
63 63
 
64 64
 
65 65
         // Register Commands
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
     private function registerTypeRoutes() {
83 83
         $routes = rglob(__DIR__.DIRECTORY_SEPARATOR."types".DIRECTORY_SEPARATOR."Route.php");
84
-        foreach($routes as $route) {
84
+        foreach ($routes as $route) {
85 85
             require $route;
86 86
         }
87 87
     }
Please login to merge, or discard this patch.
src/types/file/FileController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,21 +14,21 @@
 block discarded – undo
14 14
 {
15 15
     public function postUploadFile()
16 16
     {
17
-        if(auth()->guest()) return redirect(cb()->getLoginUrl());
17
+        if (auth()->guest()) return redirect(cb()->getLoginUrl());
18 18
 
19 19
         $file = null;
20 20
         try {
21 21
 
22 22
             cb()->validation([
23
-                'userfile' => 'required|mimes:' . implode(",",config('crudbooster.UPLOAD_FILE_EXTENSION_ALLOWED'))
23
+                'userfile' => 'required|mimes:'.implode(",", config('crudbooster.UPLOAD_FILE_EXTENSION_ALLOWED'))
24 24
             ]);
25 25
 
26 26
             $file = cb()->uploadFile('userfile', request("encrypt"));
27 27
 
28 28
         } catch (CBValidationException $e) {
29
-            return response()->json(['status'=>false,'message'=>$e->getMessage()]);
29
+            return response()->json(['status'=>false, 'message'=>$e->getMessage()]);
30 30
         } catch (\Exception $e) {
31
-            return response()->json(['status'=>false,'message'=>$e->getMessage()]);
31
+            return response()->json(['status'=>false, 'message'=>$e->getMessage()]);
32 32
         }
33 33
 
34 34
         return response()->json([
Please login to merge, or discard this patch.
src/controllers/DeveloperModulesController.php 2 patches
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
     public function getIndex() {
32 32
         $data = [];
33 33
         $data['result'] = DB::table("cb_modules")->get();
34
-        return view($this->view.'.index',$data);
34
+        return view($this->view.'.index', $data);
35 35
     }
36 36
 
37 37
     public function getAdd() {
38 38
         $data = [];
39 39
         $data['tables'] = cb()->listAllTable();
40
-        $data['module'] = (request('modules_id'))?cb()->find("cb_modules", request("modules_id")):null;
40
+        $data['module'] = (request('modules_id')) ?cb()->find("cb_modules", request("modules_id")) : null;
41 41
         return view($this->view.'.add', $data);
42 42
     }
43 43
 
@@ -50,17 +50,17 @@  discard block
 block discarded – undo
50 50
         $data = cb()->listAllColumns($table);
51 51
         $pk = cb()->findPrimaryKey($table);
52 52
         $result = [];
53
-        foreach($data as $item) {
53
+        foreach ($data as $item) {
54 54
 
55
-            if(Str::contains(strtolower($item),["title","name","label"])) {
55
+            if (Str::contains(strtolower($item), ["title", "name", "label"])) {
56 56
                 $display = true;
57
-            }else{
57
+            } else {
58 58
                 $display = false;
59 59
             }
60 60
 
61 61
             $result[] = [
62 62
                 "column"=>$item,
63
-                "primary_key"=>($pk==$item)?true:false,
63
+                "primary_key"=>($pk == $item) ?true:false,
64 64
                 "display"=>$display
65 65
             ];
66 66
         }
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 
70 70
     public function getColumns($table)
71 71
     {
72
-        if(request("modules_id")) {
73
-            $module = cb()->find("cb_modules",request("modules_id"));
74
-            if($module->last_column_build) {
72
+        if (request("modules_id")) {
73
+            $module = cb()->find("cb_modules", request("modules_id"));
74
+            if ($module->last_column_build) {
75 75
                 return response()->json(json_decode($module->last_column_build));
76 76
             }
77 77
         }
@@ -79,56 +79,56 @@  discard block
 block discarded – undo
79 79
         $columns = cb()->listAllColumns($table);
80 80
         $pk = cb()->findPrimaryKey($table);
81 81
         $result = [];
82
-        foreach($columns as $column) {
83
-            if($column != $pk) {
82
+        foreach ($columns as $column) {
83
+            if ($column != $pk) {
84 84
 
85 85
                 // Skip Column
86
-                if($column == 'deleted_at') continue;
86
+                if ($column == 'deleted_at') continue;
87 87
 
88 88
                 // Check if any relation table candidate
89 89
                 $optionTable = "";
90
-                if(Str::substr(strtolower($column),-3,3) == "_id") {
91
-                    $relationTable = Str::substr($column,0,-3);
92
-                    if(Schema::hasTable($relationTable)) {
90
+                if (Str::substr(strtolower($column), -3, 3) == "_id") {
91
+                    $relationTable = Str::substr($column, 0, -3);
92
+                    if (Schema::hasTable($relationTable)) {
93 93
                         $optionTable = $relationTable;
94 94
                     }
95
-                }elseif (Str::substr(strtolower($column),0,3) == "id_") {
96
-                    $relationTable = Str::substr($column,3);
97
-                    if(Schema::hasTable($relationTable)) {
95
+                }elseif (Str::substr(strtolower($column), 0, 3) == "id_") {
96
+                    $relationTable = Str::substr($column, 3);
97
+                    if (Schema::hasTable($relationTable)) {
98 98
                         $optionTable = $relationTable;
99 99
                     }
100 100
                 }
101 101
 
102
-                $label = trim(Str::title(str_replace(["id_","_id","_"]," ",$column)));
102
+                $label = trim(Str::title(str_replace(["id_", "_id", "_"], " ", $column)));
103 103
                 $label = Str::singular($label);
104 104
                 $type = "text";
105 105
 
106
-                if(Str::contains(strtolower($label),["photo","image","picture","gambar"])) {
106
+                if (Str::contains(strtolower($label), ["photo", "image", "picture", "gambar"])) {
107 107
                     $type = "image";
108
-                }elseif (Str::contains(strtolower($label),["email","mail"])) {
108
+                }elseif (Str::contains(strtolower($label), ["email", "mail"])) {
109 109
                     $type = "email";
110
-                }elseif (Str::contains(strtolower($label),["description","content","detail"])) {
111
-                    $type =  "wysiwyg";
112
-                }elseif (Str::contains(strtolower($label),["price","money","grand_total","tax"])) {
110
+                }elseif (Str::contains(strtolower($label), ["description", "content", "detail"])) {
111
+                    $type = "wysiwyg";
112
+                }elseif (Str::contains(strtolower($label), ["price", "money", "grand_total", "tax"])) {
113 113
                     $type = "money";
114
-                }elseif (Str::contains(strtolower($label),["quantity","qty","total","phone","telp"])) {
114
+                }elseif (Str::contains(strtolower($label), ["quantity", "qty", "total", "phone", "telp"])) {
115 115
                     $type = "number";
116
-                }elseif (Str::contains(strtolower($label),["date"])) {
116
+                }elseif (Str::contains(strtolower($label), ["date"])) {
117 117
                     $type = "date";
118 118
                 }
119 119
 
120
-                if (Str::substr(strtolower($column),-3,3) == "_id") {
120
+                if (Str::substr(strtolower($column), -3, 3) == "_id") {
121 121
                     $type = "select_table";
122 122
                 } elseif (Str::substr($column, -3, 3) == "_at") {
123 123
                     $type = "datetime";
124
-                } elseif (Str::substr($column,0, 3) == "id_") {
124
+                } elseif (Str::substr($column, 0, 3) == "id_") {
125 125
                     $type = "select_table";
126 126
                 }
127 127
 
128 128
                 $columnAdd = "on";
129 129
                 $columnEdit = "on";
130 130
                 $columnMandatory = "on";
131
-                if(in_array($column,['created_at','updated_at'])) {
131
+                if (in_array($column, ['created_at', 'updated_at'])) {
132 132
                     $columnAdd = "";
133 133
                     $columnEdit = "";
134 134
                     $columnMandatory = "";
@@ -187,39 +187,39 @@  discard block
 block discarded – undo
187 187
     public function postCreateMigration()
188 188
     {
189 189
         try {
190
-            cb()->validation(['table_name','structures']);
190
+            cb()->validation(['table_name', 'structures']);
191 191
 
192 192
             $tableName = request("table_name");
193 193
 
194
-            if(!Schema::hasTable($tableName)) {
194
+            if (!Schema::hasTable($tableName)) {
195 195
                 $filenameMigration = date("Y_m_d_His")."_".$tableName.".php";
196 196
                 $createTemplate = file_get_contents(base_path("vendor/laravel/framework/src/Illuminate/Database/Migrations/stubs/create.stub"));
197 197
                 $className = Str::studly($tableName);
198 198
                 $createTemplate = str_replace("DummyClass", $className, $createTemplate);
199 199
                 $createTemplate = str_replace("DummyTable", $tableName, $createTemplate);
200
-                $createTemplate = str_replace("\$table->increments('id');","",$createTemplate);
200
+                $createTemplate = str_replace("\$table->increments('id');", "", $createTemplate);
201 201
 
202 202
                 $structureItems = "";
203 203
 
204
-                if(request("timestamp")) {
204
+                if (request("timestamp")) {
205 205
                     $structureItems .= "\$table->timestamps();\n\t\t\t";
206 206
                 }
207 207
 
208
-                if(request("soft_deletes")) {
208
+                if (request("soft_deletes")) {
209 209
                     $structureItems .= "\$table->softDeletes();\n\t\t\t";
210 210
                 }
211 211
 
212
-                foreach(request("structures") as $item) {
212
+                foreach (request("structures") as $item) {
213 213
 
214 214
                     $nullable = "";
215 215
 
216
-                    if(!in_array($item['type_data'],["bigIncrements","increments","mediumIncrements","smallIncrements"])) {
216
+                    if (!in_array($item['type_data'], ["bigIncrements", "increments", "mediumIncrements", "smallIncrements"])) {
217 217
                         $nullable = "->nullable()";
218 218
                     }
219 219
 
220
-                    if($item['length']) {
220
+                    if ($item['length']) {
221 221
                         $structureItems .= "\$table->".$item['type_data']."('".$item['field_name']."', ".$item['length'].")$nullable;\n\t\t\t";
222
-                    }else{
222
+                    } else {
223 223
                         $structureItems .= "\$table->".$item['type_data']."('".$item['field_name']."')$nullable;\n\t\t\t";
224 224
                     }
225 225
                 }
@@ -238,12 +238,12 @@  discard block
 block discarded – undo
238 238
             }
239 239
 
240 240
         } catch (CBValidationException $e) {
241
-            return response()->json(['status'=>false,'message'=>$e->getMessage()]);
241
+            return response()->json(['status'=>false, 'message'=>$e->getMessage()]);
242 242
         } catch (\Exception $e) {
243
-            return response()->json(['status'=>false,'message'=>$e->getMessage()]);
243
+            return response()->json(['status'=>false, 'message'=>$e->getMessage()]);
244 244
         }
245 245
 
246
-        return response()->json(['status'=>true,'message'=>'Migration successfully!']);
246
+        return response()->json(['status'=>true, 'message'=>'Migration successfully!']);
247 247
     }
248 248
 
249 249
     public function postCheckExistModule()
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
         try {
252 252
             cb()->validation(['name', 'table']);
253 253
 
254
-            if(DB::table("cb_modules")->where("table_name",request("table"))->where("name",request("name"))->count()) {
254
+            if (DB::table("cb_modules")->where("table_name", request("table"))->where("name", request("name"))->count()) {
255 255
                 return response()->json(['status'=>true]);
256 256
             }
257 257
 
258 258
         } catch (CBValidationException $e) {
259
-            return response()->json(['status'=>false,'message'=>$e->getMessage()]);
259
+            return response()->json(['status'=>false, 'message'=>$e->getMessage()]);
260 260
         }
261 261
 
262 262
         return response()->json(['status'=>false]);
@@ -265,12 +265,12 @@  discard block
 block discarded – undo
265 265
     public function postAddSave() {
266 266
 
267 267
         try {
268
-            cb()->validation(['name', 'table','icon','columns']);
268
+            cb()->validation(['name', 'table', 'icon', 'columns']);
269 269
 
270 270
             $module = (new ModuleGenerator(request('table'), request('name'), request('icon'), request("columns"), request("rebuild")))->make();
271 271
 
272 272
         } catch (CBValidationException $e) {
273
-            return response()->json(['status'=>false,'message'=>$e->getMessage()]);
273
+            return response()->json(['status'=>false, 'message'=>$e->getMessage()]);
274 274
         }
275 275
 
276 276
         return response()->json(['status'=>true, 'message'=>'Please remember that you can still modify the structure by edit the controller file '.$module['controller'].' :)']);
@@ -286,9 +286,9 @@  discard block
 block discarded – undo
286 286
         try {
287 287
             cb()->validation(['name', 'icon']);
288 288
 
289
-            cb()->updateCompact("cb_modules", $id, ['name','icon']);
289
+            cb()->updateCompact("cb_modules", $id, ['name', 'icon']);
290 290
 
291
-            return cb()->redirect(route("DeveloperModulesControllerGetIndex"),"Module has been updated!","success");
291
+            return cb()->redirect(route("DeveloperModulesControllerGetIndex"), "Module has been updated!", "success");
292 292
 
293 293
         } catch (CBValidationException $e) {
294 294
             return cb()->redirectBack($e->getMessage());
@@ -296,18 +296,18 @@  discard block
 block discarded – undo
296 296
     }
297 297
 
298 298
     public function getDelete($id) {
299
-        $module = cb()->find("cb_modules",$id);
299
+        $module = cb()->find("cb_modules", $id);
300 300
         @unlink(app_path("Http/Controllers/".$module->controller.".php"));
301 301
         DB::table("cb_modules")->where("id", $id)->delete();
302 302
         DB::table("cb_menus")->where("cb_modules_id", $id)->delete();
303
-        return cb()->redirectBack("The module has been deleted!","success");
303
+        return cb()->redirectBack("The module has been deleted!", "success");
304 304
     }
305 305
 
306 306
     public function getDeleteSoft($id) {
307
-        $module = cb()->find("cb_modules",$id);
307
+        $module = cb()->find("cb_modules", $id);
308 308
         DB::table("cb_modules")->where("id", $id)->delete();
309 309
         DB::table("cb_menus")->where("cb_modules_id", $id)->delete();
310
-        return cb()->redirectBack("The module has been deleted!","success");
310
+        return cb()->redirectBack("The module has been deleted!", "success");
311 311
     }
312 312
 
313 313
 }
314 314
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +11 added lines, -9 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
             if(Str::contains(strtolower($item),["title","name","label"])) {
56 56
                 $display = true;
57
-            }else{
57
+            } else{
58 58
                 $display = false;
59 59
             }
60 60
 
@@ -83,7 +83,9 @@  discard block
 block discarded – undo
83 83
             if($column != $pk) {
84 84
 
85 85
                 // Skip Column
86
-                if($column == 'deleted_at') continue;
86
+                if($column == 'deleted_at') {
87
+                    continue;
88
+                }
87 89
 
88 90
                 // Check if any relation table candidate
89 91
                 $optionTable = "";
@@ -92,7 +94,7 @@  discard block
 block discarded – undo
92 94
                     if(Schema::hasTable($relationTable)) {
93 95
                         $optionTable = $relationTable;
94 96
                     }
95
-                }elseif (Str::substr(strtolower($column),0,3) == "id_") {
97
+                } elseif (Str::substr(strtolower($column),0,3) == "id_") {
96 98
                     $relationTable = Str::substr($column,3);
97 99
                     if(Schema::hasTable($relationTable)) {
98 100
                         $optionTable = $relationTable;
@@ -105,15 +107,15 @@  discard block
 block discarded – undo
105 107
 
106 108
                 if(Str::contains(strtolower($label),["photo","image","picture","gambar"])) {
107 109
                     $type = "image";
108
-                }elseif (Str::contains(strtolower($label),["email","mail"])) {
110
+                } elseif (Str::contains(strtolower($label),["email","mail"])) {
109 111
                     $type = "email";
110
-                }elseif (Str::contains(strtolower($label),["description","content","detail"])) {
112
+                } elseif (Str::contains(strtolower($label),["description","content","detail"])) {
111 113
                     $type =  "wysiwyg";
112
-                }elseif (Str::contains(strtolower($label),["price","money","grand_total","tax"])) {
114
+                } elseif (Str::contains(strtolower($label),["price","money","grand_total","tax"])) {
113 115
                     $type = "money";
114
-                }elseif (Str::contains(strtolower($label),["quantity","qty","total","phone","telp"])) {
116
+                } elseif (Str::contains(strtolower($label),["quantity","qty","total","phone","telp"])) {
115 117
                     $type = "number";
116
-                }elseif (Str::contains(strtolower($label),["date"])) {
118
+                } elseif (Str::contains(strtolower($label),["date"])) {
117 119
                     $type = "date";
118 120
                 }
119 121
 
@@ -219,7 +221,7 @@  discard block
 block discarded – undo
219 221
 
220 222
                     if($item['length']) {
221 223
                         $structureItems .= "\$table->".$item['type_data']."('".$item['field_name']."', ".$item['length'].")$nullable;\n\t\t\t";
222
-                    }else{
224
+                    } else{
223 225
                         $structureItems .= "\$table->".$item['type_data']."('".$item['field_name']."')$nullable;\n\t\t\t";
224 226
                     }
225 227
                 }
Please login to merge, or discard this patch.
src/configs/crudbooster.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
     /*
32 32
      * For security reason we have limit the upload file formats bellow
33 33
      */
34
-    'UPLOAD_FILE_EXTENSION_ALLOWED' => ['jpg','jpeg','png','gif','pdf','xls','xlsx','doc','docx','txt','zip','rar','rtf'],
34
+    'UPLOAD_FILE_EXTENSION_ALLOWED' => ['jpg', 'jpeg', 'png', 'gif', 'pdf', 'xls', 'xlsx', 'doc', 'docx', 'txt', 'zip', 'rar', 'rtf'],
35 35
 
36
-    'UPLOAD_IMAGE_EXTENSION_ALLOWED' => ['jpg','jpeg','png','gif'],
36
+    'UPLOAD_IMAGE_EXTENSION_ALLOWED' => ['jpg', 'jpeg', 'png', 'gif'],
37 37
 
38 38
     /*
39 39
      * You can set the upload path as you wish.
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      * You can define in this array what the tables you want to include in "php artisan crudbooster:data_migration"
68 68
      * The default is all cb_ prefix will be include in data migration
69 69
      */
70
-    'ADDITIONAL_DATA_MIGRATION'=>['users','migrations'],
70
+    'ADDITIONAL_DATA_MIGRATION'=>['users', 'migrations'],
71 71
 
72 72
 
73 73
     /*
Please login to merge, or discard this patch.
src/helpers/ModuleGenerator.php 2 patches
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -37,15 +37,15 @@  discard block
 block discarded – undo
37 37
     }
38 38
 
39 39
     public function make() {
40
-        $name = trim(($this->name)?:ucwords(str_replace("_"," ",$this->table)));
40
+        $name = trim(($this->name) ?: ucwords(str_replace("_", " ", $this->table)));
41 41
 
42 42
         $template = file_get_contents(__DIR__."/../templates/FooBarController.stub");
43 43
 
44 44
         //Replace table
45
-        $template = str_replace("{table}",'"'.$this->table.'"', $template);
45
+        $template = str_replace("{table}", '"'.$this->table.'"', $template);
46 46
 
47 47
         //Replace permalink
48
-        $permalink = strtolower(Str::slug($name,"_"));
48
+        $permalink = strtolower(Str::slug($name, "_"));
49 49
         $template = str_replace("{permalink}", '"'.$permalink.'"', $template);
50 50
 
51 51
         //Replace Page title
@@ -53,20 +53,20 @@  discard block
 block discarded – undo
53 53
 
54 54
         //Replace scaffolding
55 55
         $scaffold = "";
56
-        foreach($this->columns as $field) {
56
+        foreach ($this->columns as $field) {
57 57
             $label = $field['column_label'];
58 58
             $column = $field['column_field'];
59
-            $help = isset($field['column_help'])?"->help(\"".$field['column_help']."\")":"";
60
-            $required = ($field['column_mandatory']=="on")?"":"->required(false)";
61
-            $indexShow = ($field['column_browse']=="on")?"":"->showIndex(false)";
62
-            $detailShow = ($field['column_detail']=="on")?"":"->showDetail(false)";
63
-            $editShow = ($field['column_edit']=="on")?"":"->showEdit(false)";
64
-            $addShow = ($field['column_add']=="on")?"":"->showAdd(false)";
59
+            $help = isset($field['column_help']) ? "->help(\"".$field['column_help']."\")" : "";
60
+            $required = ($field['column_mandatory'] == "on") ? "" : "->required(false)";
61
+            $indexShow = ($field['column_browse'] == "on") ? "" : "->showIndex(false)";
62
+            $detailShow = ($field['column_detail'] == "on") ? "" : "->showDetail(false)";
63
+            $editShow = ($field['column_edit'] == "on") ? "" : "->showEdit(false)";
64
+            $addShow = ($field['column_add'] == "on") ? "" : "->showAdd(false)";
65 65
             $optionTable = $field['column_option_table'];
66 66
             $optionValue = $field['column_option_value'];
67 67
             $optionDisplay = $field['column_option_display'];
68 68
             $optionSqlCondition = $field['column_option_sql_condition'];
69
-            $optionSqlCondition = str_replace('"',"'", $optionSqlCondition);
69
+            $optionSqlCondition = str_replace('"', "'", $optionSqlCondition);
70 70
             $sqlRawQuery = $field['column_sql_query'];
71 71
             $options = $field['column_options'];
72 72
             $imageResizeWidth = $field['column_image_width'];
@@ -82,45 +82,45 @@  discard block
 block discarded – undo
82 82
             $moneyDecimalSeparator = $field['column_money_decimal_separator'];
83 83
 
84 84
             // Additional Attributes
85
-            $additional = $required . $indexShow . $detailShow . $addShow . $editShow . $help ;
85
+            $additional = $required.$indexShow.$detailShow.$addShow.$editShow.$help;
86 86
 
87 87
             // Additional money
88
-            $additional .= ($moneyPrefix && $field['column_type']=='money')?"->prefix('".$moneyPrefix."')":"";
89
-            $additional .= ($moneyPrecision && $field['column_type']=='money')?"->precision('".$moneyPrecision."')":"";
90
-            $additional .= ($moneyThousandSeparator && $field['column_type']=='money')?"->thousandSeparator('".$moneyThousandSeparator."')":"";
91
-            $additional .= ($moneyDecimalSeparator && $field['column_type']=='money')?"->decimalSeparator('".$moneyDecimalSeparator."')":"";
88
+            $additional .= ($moneyPrefix && $field['column_type'] == 'money') ? "->prefix('".$moneyPrefix."')" : "";
89
+            $additional .= ($moneyPrecision && $field['column_type'] == 'money') ? "->precision('".$moneyPrecision."')" : "";
90
+            $additional .= ($moneyThousandSeparator && $field['column_type'] == 'money') ? "->thousandSeparator('".$moneyThousandSeparator."')" : "";
91
+            $additional .= ($moneyDecimalSeparator && $field['column_type'] == 'money') ? "->decimalSeparator('".$moneyDecimalSeparator."')" : "";
92 92
 
93 93
             // Additional for image & file type
94
-            $additional .= ($fileEncrypt && in_array($field['column_type'],['file','image']))?"->encrypt(true)":"";
95
-            $additional .= ($imageResizeWidth && in_array($field['column_type'],['file','image']))?"->resize(".$imageResizeWidth.",".$imageResizeHeight.")":"";
94
+            $additional .= ($fileEncrypt && in_array($field['column_type'], ['file', 'image'])) ? "->encrypt(true)" : "";
95
+            $additional .= ($imageResizeWidth && in_array($field['column_type'], ['file', 'image'])) ? "->resize(".$imageResizeWidth.",".$imageResizeHeight.")" : "";
96 96
 
97 97
             // Additional for date & datetime
98
-            $additional .= ($dateFormat && in_array($field['column_type'],['date','datetime']))?"->format('".$dateFormat."')":"";
98
+            $additional .= ($dateFormat && in_array($field['column_type'], ['date', 'datetime'])) ? "->format('".$dateFormat."')" : "";
99 99
 
100 100
             // Additional for text
101
-            $additional .= ($textDisplayLimit!="" && in_array($field['column_type'],['text','text_area','wysiwyg']))?"->strLimit(".$textDisplayLimit.")":"";
102
-            $additional .= ($maxCharacter!="" && in_array($field['column_type'],['text','text_area']))?"->maxLength(".$maxCharacter.")":"";
103
-            $additional .= ($minCharacter!="" && in_array($field['column_type'],['text','text_area']))?"->minLength(".$minCharacter.")":"";
101
+            $additional .= ($textDisplayLimit != "" && in_array($field['column_type'], ['text', 'text_area', 'wysiwyg'])) ? "->strLimit(".$textDisplayLimit.")" : "";
102
+            $additional .= ($maxCharacter != "" && in_array($field['column_type'], ['text', 'text_area'])) ? "->maxLength(".$maxCharacter.")" : "";
103
+            $additional .= ($minCharacter != "" && in_array($field['column_type'], ['text', 'text_area'])) ? "->minLength(".$minCharacter.")" : "";
104 104
 
105 105
             $methodName = Str::studly($field['column_type']);
106
-            if($label && $column) {
107
-                if(in_array($field['column_type'],['radio','select_option','checkbox'])) {
108
-                    if($options) {
106
+            if ($label && $column) {
107
+                if (in_array($field['column_type'], ['radio', 'select_option', 'checkbox'])) {
108
+                    if ($options) {
109 109
                         $optResult = [];
110
-                        foreach($options as $opt) {
110
+                        foreach ($options as $opt) {
111 111
                             $optResult[$opt['key']] = $opt['label'];
112 112
                         }
113
-                        $scaffold .= '$this->add' . $methodName . '("' . $label . '","' . $column . '")->options('.min_var_export($optResult).')' . $additional . ';' . "\n\t\t";
113
+                        $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'")->options('.min_var_export($optResult).')'.$additional.';'."\n\t\t";
114 114
                     }
115
-                }elseif (in_array($field['column_type'],['radio_table','select_table'])) {
115
+                }elseif (in_array($field['column_type'], ['radio_table', 'select_table'])) {
116 116
                     if ($optionTable && $optionValue && $optionDisplay) {
117
-                        $scaffold .= '$this->add' . $methodName . '("' . $label . '","' . $column . '",["table"=>"' . $optionTable . '","value_option"=>"' . $optionValue . '","display_option"=>"' . $optionDisplay . '","sql_condition"=>"' . $optionSqlCondition . '"])' . $additional . ';' . "\n\t\t";
117
+                        $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'",["table"=>"'.$optionTable.'","value_option"=>"'.$optionValue.'","display_option"=>"'.$optionDisplay.'","sql_condition"=>"'.$optionSqlCondition.'"])'.$additional.';'."\n\t\t";
118 118
                     }
119 119
                 }elseif ($field['column_type'] == "select_query") {
120
-                    if($sqlRawQuery && Str::contains($sqlRawQuery,["as `key`","as `label`"])) {
121
-                        $scaffold .= '$this->add' . $methodName . '("' . $label . '","' . $column . '","'.$sqlRawQuery.'")' . $additional . ';' . "\n\t\t";
120
+                    if ($sqlRawQuery && Str::contains($sqlRawQuery, ["as `key`", "as `label`"])) {
121
+                        $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'","'.$sqlRawQuery.'")'.$additional.';'."\n\t\t";
122 122
                     }
123
-                }else{
123
+                } else {
124 124
                     $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'")'.$additional.';'."\n\t\t";
125 125
                 }
126 126
             }
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
         $module['controller'] = $filename;
144 144
         $module['last_column_build'] = json_encode($this->columns);
145 145
 
146
-        if($moduleData = DB::table("cb_modules")->where("name", $name)->where("table_name",$this->table)->first()) {
147
-            DB::table("cb_modules")->where("id",$moduleData->id)->update($module);
146
+        if ($moduleData = DB::table("cb_modules")->where("name", $name)->where("table_name", $this->table)->first()) {
147
+            DB::table("cb_modules")->where("id", $moduleData->id)->update($module);
148 148
             $id_modules = $moduleData->id;
149
-        }else{
149
+        } else {
150 150
             $id_modules = DB::table('cb_modules')->insertGetId($module);
151 151
         }
152 152
 
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
         $menu['name'] = $module['name'];
156 156
         $menu['type'] = 'module';
157 157
         $menu['cb_modules_id'] = $id_modules;
158
-        if(isset($moduleData)) {
159
-            DB::table("cb_menus")->where("cb_modules_id",$moduleData->id)->update($menu);
160
-        }else{
158
+        if (isset($moduleData)) {
159
+            DB::table("cb_menus")->where("cb_modules_id", $moduleData->id)->update($menu);
160
+        } else {
161 161
             DB::table('cb_menus')->insertGetId($menu);
162 162
         }
163 163
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
                         }
113 113
                         $scaffold .= '$this->add' . $methodName . '("' . $label . '","' . $column . '")->options('.min_var_export($optResult).')' . $additional . ';' . "\n\t\t";
114 114
                     }
115
-                }elseif (in_array($field['column_type'],['radio_table','select_table'])) {
115
+                } elseif (in_array($field['column_type'],['radio_table','select_table'])) {
116 116
                     if ($optionTable && $optionValue && $optionDisplay) {
117 117
                         $scaffold .= '$this->add' . $methodName . '("' . $label . '","' . $column . '",["table"=>"' . $optionTable . '","value_option"=>"' . $optionValue . '","display_option"=>"' . $optionDisplay . '","sql_condition"=>"' . $optionSqlCondition . '"])' . $additional . ';' . "\n\t\t";
118 118
                     }
119
-                }elseif ($field['column_type'] == "select_query") {
119
+                } elseif ($field['column_type'] == "select_query") {
120 120
                     if($sqlRawQuery && Str::contains($sqlRawQuery,["as `key`","as `label`"])) {
121 121
                         $scaffold .= '$this->add' . $methodName . '("' . $label . '","' . $column . '","'.$sqlRawQuery.'")' . $additional . ';' . "\n\t\t";
122 122
                     }
123
-                }else{
123
+                } else{
124 124
                     $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'")'.$additional.';'."\n\t\t";
125 125
                 }
126 126
             }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
         if($moduleData = DB::table("cb_modules")->where("name", $name)->where("table_name",$this->table)->first()) {
147 147
             DB::table("cb_modules")->where("id",$moduleData->id)->update($module);
148 148
             $id_modules = $moduleData->id;
149
-        }else{
149
+        } else{
150 150
             $id_modules = DB::table('cb_modules')->insertGetId($module);
151 151
         }
152 152
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         $menu['cb_modules_id'] = $id_modules;
158 158
         if(isset($moduleData)) {
159 159
             DB::table("cb_menus")->where("cb_modules_id",$moduleData->id)->update($menu);
160
-        }else{
160
+        } else{
161 161
             DB::table('cb_menus')->insertGetId($menu);
162 162
         }
163 163
 
Please login to merge, or discard this patch.
src/helpers/CB.php 2 patches
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 {
21 21
 
22 22
     public function getRoleByName($roleName) {
23
-        return $this->find("cb_roles",['name'=>$roleName]);
23
+        return $this->find("cb_roles", ['name'=>$roleName]);
24 24
     }
25 25
 
26 26
     public function fcm() {
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     }
37 37
 
38 38
     public function getDeveloperUrl($path = null) {
39
-        $path = ($path)?"/".trim($path,"/"):null;
39
+        $path = ($path) ? "/".trim($path, "/") : null;
40 40
         return url("developer/".getSetting("developer_path")).$path;
41 41
     }
42 42
 
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
     }
54 54
 
55 55
     public function getAdminUrl($path = null) {
56
-        $path = ($path)?"/".trim($path,"/"):null;
56
+        $path = ($path) ? "/".trim($path, "/") : null;
57 57
         return url(cbConfig("ADMIN_PATH")).$path;
58 58
     }
59 59
 
60 60
     public function getAppName() {
61
-        return env("APP_NAME","CRUDBOOSTER");
61
+        return env("APP_NAME", "CRUDBOOSTER");
62 62
     }
63 63
 
64 64
     /**
@@ -71,17 +71,17 @@  discard block
 block discarded – undo
71 71
      */
72 72
     private function uploadFileProcess($filename, $extension, $encrypt = true, $resize_width = null, $resize_height = null)
73 73
     {
74
-        if(in_array($extension,cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) {
74
+        if (in_array($extension, cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) {
75 75
             $filename = slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME));
76 76
             $file_path = cbConfig("UPLOAD_PATH_FORMAT");
77
-            $file_path = str_replace("{Y}",date('Y'), $file_path);
77
+            $file_path = str_replace("{Y}", date('Y'), $file_path);
78 78
             $file_path = str_replace("{m}", date('m'), $file_path);
79 79
             $file_path = str_replace("{d}", date("d"), $file_path);
80 80
 
81 81
             //Create Directory Base On Template
82 82
             Storage::makeDirectory($file_path);
83
-            Storage::put($file_path."/index.html","&nbsp;","public");
84
-            Storage::put($file_path."/.gitignore","!.gitignore","public");
83
+            Storage::put($file_path."/index.html", "&nbsp;", "public");
84
+            Storage::put($file_path."/.gitignore", "!.gitignore", "public");
85 85
 
86 86
             if ($encrypt == true) {
87 87
                 $filename = md5(strRandom(5)).'.'.$extension;
@@ -89,17 +89,17 @@  discard block
 block discarded – undo
89 89
                 $filename = slug($filename, '_').'.'.$extension;
90 90
             }
91 91
 
92
-            if($resize_width || $resize_height) {
92
+            if ($resize_width || $resize_height) {
93 93
                 $this->resizeImage($file, $file_path.'/'.$filename, $resize_width, $resize_height);
94 94
                 return $file_path.'/'.$filename;
95
-            }else{
95
+            } else {
96 96
                 if (Storage::put($file_path.'/'.$filename, $file, 'public')) {
97 97
                     return $file_path.'/'.$filename;
98 98
                 } else {
99 99
                     throw new \Exception("Something went wrong, file can't upload!");
100 100
                 }
101 101
             }
102
-        }else{
102
+        } else {
103 103
             throw new \Exception("The file format is not allowed!");
104 104
         }
105 105
     }
@@ -115,16 +115,16 @@  discard block
 block discarded – undo
115 115
     {
116 116
         $fileData = base64_decode($base64_value);
117 117
         $mime_type = finfo_buffer(finfo_open(), $fileData, FILEINFO_MIME_TYPE);
118
-        if($mime_type) {
119
-            if($mime_type = explode('/', $mime_type)) {
118
+        if ($mime_type) {
119
+            if ($mime_type = explode('/', $mime_type)) {
120 120
                 $ext = $mime_type[1];
121
-                if($filename && $ext) {
121
+                if ($filename && $ext) {
122 122
                     return $this->uploadFileProcess($filename, $ext, $encrypt, $resize_width, $resize_height);
123 123
                 }
124
-            }else {
124
+            } else {
125 125
                 throw new \Exception("Mime type not found");
126 126
             }
127
-        }else{
127
+        } else {
128 128
             throw new \Exception("Mime type not found");
129 129
         }
130 130
     }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
             $filename = $file->getClientOriginalName();
145 145
             $ext = strtolower($file->getClientOriginalExtension());
146 146
 
147
-            if($filename && $ext) {
147
+            if ($filename && $ext) {
148 148
                 return $this->uploadFileProcess($filename, $ext, $encrypt, $resize_width, $resize_height);
149 149
             }
150 150
 
@@ -179,29 +179,29 @@  discard block
 block discarded – undo
179 179
             if ($resize_width && $resize_height) {
180 180
                 $img->fit($resize_width, $resize_height);
181 181
 
182
-            } elseif ($resize_width && ! $resize_height) {
182
+            } elseif ($resize_width && !$resize_height) {
183 183
 
184
-                $img->resize($resize_width, null, function ($constraint) {
184
+                $img->resize($resize_width, null, function($constraint) {
185 185
                     $constraint->aspectRatio();
186 186
                 });
187 187
 
188
-            } elseif (! $resize_width && $resize_height) {
188
+            } elseif (!$resize_width && $resize_height) {
189 189
 
190
-                $img->resize(null, $resize_height, function ($constraint) {
190
+                $img->resize(null, $resize_height, function($constraint) {
191 191
                     $constraint->aspectRatio();
192 192
                 });
193 193
 
194 194
             } else {
195 195
 
196 196
                 if ($img->width() > cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES")) {
197
-                    $img->resize(cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES"), null, function ($constraint) {
197
+                    $img->resize(cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES"), null, function($constraint) {
198 198
                         $constraint->aspectRatio();
199 199
                     });
200 200
                 }
201 201
             }
202 202
 
203 203
             Storage::put($fullFilePath, $img, 'public');
204
-        }else{
204
+        } else {
205 205
             throw new \Exception("The file format is not allowed!");
206 206
         }
207 207
     }
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
         $validator = Validator::make($input_arr, $rules, $messages);
315 315
         if ($validator->fails()) {
316 316
             $message = $validator->errors()->all();
317
-            throw new CBValidationException(implode("; ",$message));
317
+            throw new CBValidationException(implode("; ", $message));
318 318
         }
319 319
     }
320 320
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
     public function findPrimaryKey($table)
327 327
     {
328 328
         $pk = DB::getDoctrineSchemaManager()->listTableDetails($table)->getPrimaryKey();
329
-        if(!$pk) {
329
+        if (!$pk) {
330 330
             return null;
331 331
         }
332 332
         return $pk->getColumns()[0];
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
             $string_parameters_array = explode('&', $string_parameters);
376 376
             foreach ($string_parameters_array as $s) {
377 377
                 $part = explode('=', $s);
378
-                if(isset($part[0]) && isset($part[1])) {
378
+                if (isset($part[0]) && isset($part[1])) {
379 379
                     $name = htmlspecialchars(urldecode($part[0]));
380 380
                     $name = strip_tags($name);
381 381
                     $value = htmlspecialchars(urldecode($part[1]));
@@ -392,16 +392,16 @@  discard block
 block discarded – undo
392 392
 
393 393
 
394 394
     public function routeGet($prefix, $controller) {
395
-        $alias = str_replace("@"," ", $controller);
395
+        $alias = str_replace("@", " ", $controller);
396 396
         $alias = ucwords($alias);
397
-        $alias = str_replace(" ","",$alias);
397
+        $alias = str_replace(" ", "", $alias);
398 398
         Route::get($prefix, ['uses' => $controller, 'as' => $alias]);
399 399
     }
400 400
 
401 401
     public function routePost($prefix, $controller) {
402
-        $alias = str_replace("@"," ", $controller);
402
+        $alias = str_replace("@", " ", $controller);
403 403
         $alias = ucwords($alias);
404
-        $alias = str_replace(" ","",$alias);
404
+        $alias = str_replace(" ", "", $alias);
405 405
         Route::post($prefix, ['uses' => $controller, 'as' => $alias]);
406 406
     }
407 407
 
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 
427 427
         $prefix = trim($prefix, '/').'/';
428 428
 
429
-        if(substr($controller,0,1) != "\\") {
429
+        if (substr($controller, 0, 1) != "\\") {
430 430
             $controller = "\App\Http\Controllers\\".$controller;
431 431
         }
432 432
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -92,14 +92,14 @@  discard block
 block discarded – undo
92 92
             if($resize_width || $resize_height) {
93 93
                 $this->resizeImage($file, $file_path.'/'.$filename, $resize_width, $resize_height);
94 94
                 return $file_path.'/'.$filename;
95
-            }else{
95
+            } else{
96 96
                 if (Storage::put($file_path.'/'.$filename, $file, 'public')) {
97 97
                     return $file_path.'/'.$filename;
98 98
                 } else {
99 99
                     throw new \Exception("Something went wrong, file can't upload!");
100 100
                 }
101 101
             }
102
-        }else{
102
+        } else{
103 103
             throw new \Exception("The file format is not allowed!");
104 104
         }
105 105
     }
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
                 if($filename && $ext) {
122 122
                     return $this->uploadFileProcess($filename, $ext, $encrypt, $resize_width, $resize_height);
123 123
                 }
124
-            }else {
124
+            } else {
125 125
                 throw new \Exception("Mime type not found");
126 126
             }
127
-        }else{
127
+        } else{
128 128
             throw new \Exception("Mime type not found");
129 129
         }
130 130
     }
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
             }
202 202
 
203 203
             Storage::put($fullFilePath, $img, 'public');
204
-        }else{
204
+        } else{
205 205
             throw new \Exception("The file format is not allowed!");
206 206
         }
207 207
     }
Please login to merge, or discard this patch.
src/helpers/Helper.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 |
10 10
 */
11 11
 
12
-if(!function_exists("cbLang")) {
12
+if (!function_exists("cbLang")) {
13 13
     /**
14 14
      * @param string $key
15 15
      * @param array $replace
@@ -21,17 +21,17 @@  discard block
 block discarded – undo
21 21
     }
22 22
 }
23 23
 
24
-if(!function_exists('rglob')) {
24
+if (!function_exists('rglob')) {
25 25
     function rglob($pattern, $flags = 0) {
26 26
         $files = glob($pattern, $flags);
27
-        foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
27
+        foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
28 28
             $files = array_merge($files, rglob($dir.'/'.basename($pattern), $flags));
29 29
         }
30 30
         return $files;
31 31
     }
32 32
 }
33 33
 
34
-if(!function_exists('convertPHPToMomentFormat')) {
34
+if (!function_exists('convertPHPToMomentFormat')) {
35 35
     function convertPHPToMomentFormat($format)
36 36
     {
37 37
         $replacements = [
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
     }
79 79
 }
80 80
 
81
-if(!function_exists('slug')) {
81
+if (!function_exists('slug')) {
82 82
     function slug($string, $separator = '-') {
83 83
         return \Illuminate\Support\Str::slug($string, $separator);
84 84
     }
85 85
 }
86 86
 
87
-if(!function_exists('columnSingleton')) {
87
+if (!function_exists('columnSingleton')) {
88 88
     /**
89 89
      * @return \crocodicstudio\crudbooster\controllers\scaffolding\singletons\ColumnSingleton
90 90
      */
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     }
94 94
 }
95 95
 
96
-if(!function_exists('cbHook'))
96
+if (!function_exists('cbHook'))
97 97
 {
98 98
     /**
99 99
      * @return crocodicstudio\crudbooster\hooks\CBHook
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     }
106 106
 }
107 107
 
108
-if(!function_exists('getTypeHook'))
108
+if (!function_exists('getTypeHook'))
109 109
 {
110 110
     /**
111 111
      * @param string $type
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     }
119 119
 }
120 120
 
121
-if(!function_exists('getPrimaryKey'))
121
+if (!function_exists('getPrimaryKey'))
122 122
 {
123 123
     function getPrimaryKey($table_name)
124 124
     {
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     }
127 127
 }
128 128
 
129
-if(!function_exists('cb'))
129
+if (!function_exists('cb'))
130 130
 {
131 131
     function cb()
132 132
     {
@@ -134,25 +134,25 @@  discard block
 block discarded – undo
134 134
     }
135 135
 }
136 136
 
137
-if(!function_exists('cbAsset')) {
137
+if (!function_exists('cbAsset')) {
138 138
     function cbAsset($path) {
139 139
         return asset("cb_asset/".$path);
140 140
     }
141 141
 }
142 142
 
143
-if(!function_exists("cbConfig")) {
143
+if (!function_exists("cbConfig")) {
144 144
     function cbConfig($name) {
145 145
         return config("crudbooster.".$name);
146 146
     }
147 147
 }
148 148
 
149
-if(!function_exists("strRandom")) {
149
+if (!function_exists("strRandom")) {
150 150
     function strRandom($length = 5) {
151 151
         return \Illuminate\Support\Str::random($length);
152 152
     }
153 153
 }
154 154
 
155
-if(!function_exists('module')) {
155
+if (!function_exists('module')) {
156 156
     function module()
157 157
     {
158 158
         $module = new \crocodicstudio\crudbooster\helpers\Module();
@@ -160,43 +160,43 @@  discard block
 block discarded – undo
160 160
     }
161 161
 }
162 162
 
163
-if(!function_exists('getAdminLoginURL')) {
163
+if (!function_exists('getAdminLoginURL')) {
164 164
     function getAdminLoginURL()
165 165
     {
166 166
         return url(config('crudbooster.ADMIN_LOGIN_PATH'));
167 167
     }
168 168
 }
169 169
 
170
-if(!function_exists('dummyPhoto')) {
170
+if (!function_exists('dummyPhoto')) {
171 171
     function dummyPhoto()
172 172
     {
173 173
         return config('crudbooster.DUMMY_PHOTO');
174 174
     }
175 175
 }
176 176
 
177
-if(!function_exists('assetThumbnail')) {
177
+if (!function_exists('assetThumbnail')) {
178 178
 	function assetThumbnail($path) {
179
-		$path = str_replace('uploads/','uploads_thumbnail/',$path);
179
+		$path = str_replace('uploads/', 'uploads_thumbnail/', $path);
180 180
 		return asset($path);
181 181
 	}
182 182
 }
183 183
 
184
-if(!function_exists('assetResize')) {
185
-	function assetResize($path,$width,$height=null,$quality=70) {
184
+if (!function_exists('assetResize')) {
185
+	function assetResize($path, $width, $height = null, $quality = 70) {
186 186
 		$basename = basename($path);
187 187
 	    $pathWithoutName = str_replace($basename, '', $path);
188 188
 	    $newLocation = $pathWithoutName.'/w_'.$width.'_h_'.$height.'_'.$basename;
189
-	    if(Storage::exists($newLocation)) {
189
+	    if (Storage::exists($newLocation)) {
190 190
 	        return asset($newLocation);
191
-	    }else{
192
-	        $img = Image::make(storage_path($path))->fit($width,$height);
193
-	        $img->save(storage_path($newLocation),$quality);
191
+	    } else {
192
+	        $img = Image::make(storage_path($path))->fit($width, $height);
193
+	        $img->save(storage_path($newLocation), $quality);
194 194
 	        return asset($newLocation);
195 195
 	    }
196 196
 	}
197 197
 }
198 198
 
199
-if(!function_exists('extract_unit')) {	
199
+if (!function_exists('extract_unit')) {	
200 200
 	/*
201 201
 	Credits: Bit Repository
202 202
 	URL: http://www.bitrepository.com/extract-content-between-two-delimiters-with-php.html
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 }
215 215
 
216 216
 
217
-if(!function_exists('now')) {
217
+if (!function_exists('now')) {
218 218
 	function now() {		
219 219
 		return date('Y-m-d H:i:s');
220 220
 	}
@@ -228,14 +228,14 @@  discard block
 block discarded – undo
228 228
 |
229 229
 */
230 230
 
231
-if(!function_exists('putSetting')) {
231
+if (!function_exists('putSetting')) {
232 232
     function putSetting($key, $value)
233 233
     {
234
-        if(file_exists(storage_path('.cbconfig'))) {
234
+        if (file_exists(storage_path('.cbconfig'))) {
235 235
             $settings = file_get_contents(storage_path('.cbconfig'));
236 236
             $settings = decrypt($settings);
237 237
             $settings = unserialize($settings);
238
-        }else{
238
+        } else {
239 239
             $settings = [];
240 240
         }
241 241
 
@@ -247,26 +247,26 @@  discard block
 block discarded – undo
247 247
     }
248 248
 }
249 249
 
250
-if(!function_exists('getSetting')) {
250
+if (!function_exists('getSetting')) {
251 251
     function getSetting($key, $default = null)
252 252
     {
253
-        if(file_exists(storage_path('.cbconfig'))) {
253
+        if (file_exists(storage_path('.cbconfig'))) {
254 254
             $settings = file_get_contents(storage_path('.cbconfig'));
255 255
             $settings = decrypt($settings);
256 256
             $settings = unserialize($settings);
257
-        }else{
257
+        } else {
258 258
             $settings = [];
259 259
         }
260 260
 
261
-        if(isset($settings[$key])) {
262
-            return $settings[$key]?:$default;
263
-        }else{
261
+        if (isset($settings[$key])) {
262
+            return $settings[$key] ?: $default;
263
+        } else {
264 264
             return $default;
265 265
         }
266 266
     }
267 267
 }
268 268
 
269
-if(!function_exists('timeAgo')) {
269
+if (!function_exists('timeAgo')) {
270 270
     function timeAgo($datetime_to, $datetime_from = null, $full = false)
271 271
     {
272 272
         $datetime_from = ($datetime_from) ?: date('Y-m-d H:i:s');
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
             }
298 298
         }
299 299
 
300
-        if (! $full) {
300
+        if (!$full) {
301 301
             $string = array_slice($string, 0, 1);
302 302
         }
303 303
 
@@ -305,22 +305,22 @@  discard block
 block discarded – undo
305 305
     }
306 306
 }
307 307
 
308
-if(!function_exists("array_map_r")) {
309
-    function array_map_r( $func, $arr )
308
+if (!function_exists("array_map_r")) {
309
+    function array_map_r($func, $arr)
310 310
     {
311 311
         $newArr = array();
312 312
 
313
-        foreach( $arr as $key => $value )
313
+        foreach ($arr as $key => $value)
314 314
         {
315 315
             $key = $func($key);
316
-            $newArr[ $key ] = ( is_array( $value ) ? array_map_r( $func, $value ) : ( is_array($func) ? call_user_func_array($func, $value) : $func( $value ) ) );
316
+            $newArr[$key] = (is_array($value) ? array_map_r($func, $value) : (is_array($func) ? call_user_func_array($func, $value) : $func($value)));
317 317
         }
318 318
 
319 319
         return $newArr;
320 320
     }
321 321
 }
322 322
 
323
-if(!function_exists("sanitizeXSS"))
323
+if (!function_exists("sanitizeXSS"))
324 324
 {
325 325
     function sanitizeXSS($value)
326 326
     {
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
     }
333 333
 }
334 334
 
335
-if(!function_exists("requestAll")) {
335
+if (!function_exists("requestAll")) {
336 336
     function requestAll() {
337 337
         $all = array_map_r("sanitizeXSS", request()->all());
338 338
         return $all;
@@ -341,22 +341,22 @@  discard block
 block discarded – undo
341 341
 
342 342
 
343 343
 
344
-if(!function_exists('getURLFormat')) {
344
+if (!function_exists('getURLFormat')) {
345 345
     function getURLFormat($name) {
346 346
         $url = request($name);
347
-        if(filter_var($url, FILTER_VALIDATE_URL)) {
347
+        if (filter_var($url, FILTER_VALIDATE_URL)) {
348 348
             return $url;
349
-        }else{
349
+        } else {
350 350
             return request()->url();
351 351
         }
352 352
     }
353 353
 }
354 354
 
355
-if(!function_exists('g')) {
355
+if (!function_exists('g')) {
356 356
     function g($name, $safe = true) {
357
-        if($safe == true) {
357
+        if ($safe == true) {
358 358
             $response = request($name);
359
-            if(is_string($response)) {
359
+            if (is_string($response)) {
360 360
                 $response = sanitizeXSS($response);
361 361
             }elseif (is_array($response)) {
362 362
                 array_walk_recursive($response, function(&$response) {
@@ -365,25 +365,25 @@  discard block
 block discarded – undo
365 365
             }
366 366
 
367 367
             return $response;
368
-        }else{
368
+        } else {
369 369
             return Request::get($name);
370 370
         }
371 371
     }
372 372
 }
373 373
 
374
-if(!function_exists('min_var_export')) {
374
+if (!function_exists('min_var_export')) {
375 375
     function min_var_export($input) {
376
-        if(is_array($input)) {
376
+        if (is_array($input)) {
377 377
             $buffer = [];
378
-            foreach($input as $key => $value)
378
+            foreach ($input as $key => $value)
379 379
                 $buffer[] = var_export($key, true)."=>".min_var_export($value);
380
-            return "[".implode(",",$buffer)."]";
380
+            return "[".implode(",", $buffer)."]";
381 381
         } else
382 382
             return var_export($input, true);
383 383
     }
384 384
 }
385 385
 
386
-if(!function_exists('rrmdir')) {
386
+if (!function_exists('rrmdir')) {
387 387
 	/*
388 388
 	* http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir
389 389
 	*/
Please login to merge, or discard this patch.