Passed
Push — master ( db0af9...5e9f02 )
by Ferry
03:57
created
src/controllers/DeveloperRolesController.php 2 patches
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@  discard block
 block discarded – undo
25 25
     public function getIndex() {
26 26
         $data = [];
27 27
         $data['result'] = DB::table("cb_roles")->get();
28
-        return view($this->view.".index",$data);
28
+        return view($this->view.".index", $data);
29 29
     }
30 30
 
31 31
     public function getAdd() {
32 32
         $data = [];
33
-        $data['menus'] = DB::table("cb_menus")->orderBy("name","asc")->get();
33
+        $data['menus'] = DB::table("cb_menus")->orderBy("name", "asc")->get();
34 34
         return view($this->view.".add", $data);
35 35
     }
36 36
 
@@ -49,17 +49,17 @@  discard block
 block discarded – undo
49 49
                 $privilege = [];
50 50
                 $privilege["cb_roles_id"] = $roles_id;
51 51
                 $privilege["cb_menus_id"] = $menus_id;
52
-                $privilege["can_browse"]  = @$access['can_browse']?:0;
53
-                $privilege["can_create"] = @$access['can_create']?:0;
54
-                $privilege["can_read"] = @$access['can_read']?:0;
55
-                $privilege["can_update"] = @$access['can_update']?:0;
56
-                $privilege["can_delete"] = @$access['can_delete']?:0;
52
+                $privilege["can_browse"]  = @$access['can_browse'] ?: 0;
53
+                $privilege["can_create"] = @$access['can_create'] ?: 0;
54
+                $privilege["can_read"] = @$access['can_read'] ?: 0;
55
+                $privilege["can_update"] = @$access['can_update'] ?: 0;
56
+                $privilege["can_delete"] = @$access['can_delete'] ?: 0;
57 57
                 DB::table("cb_role_privileges")->insert($privilege);
58 58
             }
59 59
 
60 60
             DB::commit();
61 61
 
62
-            return cb()->redirect(route("DeveloperRolesControllerGetIndex"),"The role has been saved!","success");
62
+            return cb()->redirect(route("DeveloperRolesControllerGetIndex"), "The role has been saved!", "success");
63 63
 
64 64
         } catch (CBValidationException $e) {
65 65
             return cb()->redirectBack($e->getMessage());
@@ -74,21 +74,21 @@  discard block
 block discarded – undo
74 74
         $data['row'] = cb()->find("cb_roles", $id);
75 75
 
76 76
         $menus = DB::table("cb_menus")
77
-        ->leftjoin("cb_role_privileges",function($join) use ($id) {
78
-            $join->on("cb_role_privileges.cb_menus_id","=","cb_menus.id")->where("cb_role_privileges.cb_roles_id", $id);
77
+        ->leftjoin("cb_role_privileges", function($join) use ($id) {
78
+            $join->on("cb_role_privileges.cb_menus_id", "=", "cb_menus.id")->where("cb_role_privileges.cb_roles_id", $id);
79 79
         })
80
-        ->orderBy("cb_menus.name","asc")
81
-        ->select("cb_menus.*","can_browse","can_create","can_read","can_update","can_delete")
80
+        ->orderBy("cb_menus.name", "asc")
81
+        ->select("cb_menus.*", "can_browse", "can_create", "can_read", "can_update", "can_delete")
82 82
         ->get();
83 83
         $data['menus'] = $menus;
84 84
 
85
-        return view($this->view.".edit",$data);
85
+        return view($this->view.".edit", $data);
86 86
     }
87 87
 
88 88
     private function existsPrivilege($cb_roles_id, $cb_menus_id) {
89
-        if($row = cb()->find("cb_role_privileges",['cb_roles_id'=>$cb_roles_id,'cb_menus_id'=>$cb_menus_id])) {
89
+        if ($row = cb()->find("cb_role_privileges", ['cb_roles_id'=>$cb_roles_id, 'cb_menus_id'=>$cb_menus_id])) {
90 90
             return $row->id;
91
-        }else{
91
+        } else {
92 92
             return null;
93 93
         }
94 94
     }
@@ -97,26 +97,26 @@  discard block
 block discarded – undo
97 97
         try {
98 98
             cb()->validation(['name', 'menus']);
99 99
 
100
-            cb()->updateCompact("cb_roles",$id,['name']);
100
+            cb()->updateCompact("cb_roles", $id, ['name']);
101 101
 
102 102
             foreach (request("menus") as $menus_id) {
103 103
                 @$access = request("access")[$menus_id];
104 104
                 $privilege = [];
105 105
                 $privilege["cb_roles_id"] = $id;
106 106
                 $privilege["cb_menus_id"] = $menus_id;
107
-                $privilege["can_browse"]  = @$access['can_browse']?:0;
108
-                $privilege["can_create"] = @$access['can_create']?:0;
109
-                $privilege["can_read"] = @$access['can_read']?:0;
110
-                $privilege["can_update"] = @$access['can_update']?:0;
111
-                $privilege["can_delete"] = @$access['can_delete']?:0;
112
-                if($privilege_id = $this->existsPrivilege($id, $menus_id)) {
107
+                $privilege["can_browse"]  = @$access['can_browse'] ?: 0;
108
+                $privilege["can_create"] = @$access['can_create'] ?: 0;
109
+                $privilege["can_read"] = @$access['can_read'] ?: 0;
110
+                $privilege["can_update"] = @$access['can_update'] ?: 0;
111
+                $privilege["can_delete"] = @$access['can_delete'] ?: 0;
112
+                if ($privilege_id = $this->existsPrivilege($id, $menus_id)) {
113 113
                     DB::table("cb_role_privileges")->where("id", $privilege_id)->update($privilege);
114
-                }else{
114
+                } else {
115 115
                     DB::table("cb_role_privileges")->insert($privilege);
116 116
                 }
117 117
             }
118 118
 
119
-            return cb()->redirect(route("DeveloperRolesControllerGetIndex"),"The role has been saved!","success");
119
+            return cb()->redirect(route("DeveloperRolesControllerGetIndex"), "The role has been saved!", "success");
120 120
 
121 121
         } catch (CBValidationException $e) {
122 122
 
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 
127 127
     public function getDelete($id) {
128 128
         DB::table("cb_roles")->where("id", $id)->delete();
129
-        DB::table("cb_role_privileges")->where("cb_roles_id",$id)->delete();
129
+        DB::table("cb_role_privileges")->where("cb_roles_id", $id)->delete();
130 130
 
131
-        return cb()->redirect(route("DeveloperRolesControllerGetIndex"), "The role has been deleted!","success");
131
+        return cb()->redirect(route("DeveloperRolesControllerGetIndex"), "The role has been deleted!", "success");
132 132
     }
133 133
 
134 134
 }
135 135
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     private function existsPrivilege($cb_roles_id, $cb_menus_id) {
89 89
         if($row = cb()->find("cb_role_privileges",['cb_roles_id'=>$cb_roles_id,'cb_menus_id'=>$cb_menus_id])) {
90 90
             return $row->id;
91
-        }else{
91
+        } else{
92 92
             return null;
93 93
         }
94 94
     }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
                 $privilege["can_delete"] = @$access['can_delete']?:0;
112 112
                 if($privilege_id = $this->existsPrivilege($id, $menus_id)) {
113 113
                     DB::table("cb_role_privileges")->where("id", $privilege_id)->update($privilege);
114
-                }else{
114
+                } else{
115 115
                     DB::table("cb_role_privileges")->insert($privilege);
116 116
                 }
117 117
             }
Please login to merge, or discard this patch.
src/types/select_option/SelectOption.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@
 block discarded – undo
21 21
     public function options($data_options) {
22 22
         $data = columnSingleton()->getColumn($this->index);
23 23
 
24
-        foreach($data_options as $key=>$option) {
25
-            if(is_int($key)) {
24
+        foreach ($data_options as $key=>$option) {
25
+            if (is_int($key)) {
26 26
                 $data_options[$option] = $option;
27
-            }else{
27
+            } else {
28 28
                 $data_options[$key] = $option;
29 29
             }
30 30
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
         foreach($data_options as $key=>$option) {
25 25
             if(is_int($key)) {
26 26
                 $data_options[$option] = $option;
27
-            }else{
27
+            } else{
28 28
                 $data_options[$key] = $option;
29 29
             }
30 30
         }
Please login to merge, or discard this patch.
src/types/select_option/component.blade.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
             name="{{ $column->getName() }}" id="{{ $column->getName() }}">
8 8
         <option value="">** Select a {{ $column->getLabel() }}</option>
9 9
         <?php
10
-            $columnValue = old($column->getName())?:($column->getDefaultValue())?:$column->getValue();
10
+            $columnValue = old($column->getName()) ?: ($column->getDefaultValue()) ?: $column->getValue();
11 11
         ?>
12 12
         @foreach($column->getOptions() as $key=>$value)
13 13
             <option {{ $columnValue==$key?'selected':'' }} value="{{ $key }}">{{ $value }}</option>
Please login to merge, or discard this patch.
src/types/select_option/Hook.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
     {
22 22
         $option = $column->getOptions();
23 23
         $key = $row->{ $column->getField() };
24
-        return @$option[ $key ];
24
+        return @$option[$key];
25 25
     }
26 26
 
27 27
     public function detailRender($row, $column)
Please login to merge, or discard this patch.
src/types/select_table/Route.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-cb()->routeGroupBackend(function () {
4
-    cb()->routePost("select-table-lookup",'\crocodicstudio\crudbooster\types\select_table\SelectTableController@postLookup');
3
+cb()->routeGroupBackend(function() {
4
+    cb()->routePost("select-table-lookup", '\crocodicstudio\crudbooster\types\select_table\SelectTableController@postLookup');
5 5
 });
6 6
\ No newline at end of file
Please login to merge, or discard this patch.
src/types/select_table/component.blade.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
         <option value="">** Select a {{ $column->getLabel() }}</option>
9 9
         @if(!$column->getForeignKey())
10 10
             <?php
11
-                $columnValue = old($column->getName())?:($column->getDefaultValue())?:$column->getValue();
11
+                $columnValue = old($column->getName()) ?: ($column->getDefaultValue()) ?: $column->getValue();
12 12
             ?>
13 13
             @foreach($column->getOptions() as $key=>$value)
14 14
                 <option {{ $columnValue==$key?'selected':'' }} value="{{ $key }}">{{ $value }}</option>
Please login to merge, or discard this patch.
src/types/select_table/Hook.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
         if($column->getOptionsFromTable()) {
37 37
             $option = $column->getOptionsFromTable();
38 38
             return $row->{ $option['table'].'_'.$option['display_field'] };
39
-        }else{
39
+        } else{
40 40
             $option = $column->getOptions();
41 41
             $key = $row->{ $column->getField() };
42 42
             return @$option[ $key ];
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
      */
20 20
     public function query($query, $column)
21 21
     {
22
-        if($option = $column->getOptionsFromTable()) {
23
-            $query->leftjoin($option["table"],$option["table"].'.'.$option["primary_key"],"=", $column->getField());
22
+        if ($option = $column->getOptionsFromTable()) {
23
+            $query->leftjoin($option["table"], $option["table"].'.'.$option["primary_key"], "=", $column->getField());
24 24
             $query->addSelect($option['table'].'.'.$option['display_field'].' as '.$option['table'].'_'.$option['display_field']);
25 25
         }
26 26
         return $query;
@@ -32,13 +32,13 @@  discard block
 block discarded – undo
32 32
      */
33 33
     public function indexRender($row, $column)
34 34
     {
35
-        if($column->getOptionsFromTable()) {
35
+        if ($column->getOptionsFromTable()) {
36 36
             $option = $column->getOptionsFromTable();
37 37
             return $row->{ $option['table'].'_'.$option['display_field'] };
38
-        }else{
38
+        } else {
39 39
             $option = $column->getOptions();
40 40
             $key = $row->{ $column->getField() };
41
-            return @$option[ $key ];
41
+            return @$option[$key];
42 42
         }
43 43
     }
44 44
 
Please login to merge, or discard this patch.
src/types/select_table/SelectTableController.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
         $foreignValue = request('foreign_value');
19 19
         $table = decrypt(request('table'));
20 20
         $sqlCondition = decrypt(request('sql_condition'));
21
-        if($foreignKey && $foreignValue && $table) {
21
+        if ($foreignKey && $foreignValue && $table) {
22 22
 
23 23
             $data = DB::table($table)
24 24
                 ->where($foreignKey, $foreignValue);
25
-            if($sqlCondition) {
25
+            if ($sqlCondition) {
26 26
                 $data->whereRaw($sqlCondition);
27 27
             }
28 28
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
             return response()->json(['status'=>true, 'data'=>$data], 200, ["X-Frame-Options"=>"SAMEORIGIN"]);
32 32
 
33
-        }else{
33
+        } else {
34 34
             return response()->json(['status'=>false]);
35 35
         }
36 36
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 
31 31
             return response()->json(['status'=>true, 'data'=>$data], 200, ["X-Frame-Options"=>"SAMEORIGIN"]);
32 32
 
33
-        }else{
33
+        } else{
34 34
             return response()->json(['status'=>false]);
35 35
         }
36 36
     }
Please login to merge, or discard this patch.
src/controllers/DeveloperModulesController.php 2 patches
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.
Spacing   +49 added lines, -49 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,30 +265,30 @@  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'].' :)']);
277 277
     }
278 278
 
279 279
     public function getDelete($id) {
280
-        $module = cb()->find("cb_modules",$id);
280
+        $module = cb()->find("cb_modules", $id);
281 281
         @unlink(app_path("Http/Controllers/".$module->controller.".php"));
282 282
         DB::table("cb_modules")->where("id", $id)->delete();
283 283
         DB::table("cb_menus")->where("cb_modules_id", $id)->delete();
284
-        return cb()->redirectBack("The module has been deleted!","success");
284
+        return cb()->redirectBack("The module has been deleted!", "success");
285 285
     }
286 286
 
287 287
     public function getDeleteSoft($id) {
288
-        $module = cb()->find("cb_modules",$id);
288
+        $module = cb()->find("cb_modules", $id);
289 289
         DB::table("cb_modules")->where("id", $id)->delete();
290 290
         DB::table("cb_menus")->where("cb_modules_id", $id)->delete();
291
-        return cb()->redirectBack("The module has been deleted!","success");
291
+        return cb()->redirectBack("The module has been deleted!", "success");
292 292
     }
293 293
 
294 294
 }
295 295
\ No newline at end of file
Please login to merge, or discard this patch.