@@ -36,7 +36,7 @@ |
||
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 ]; |
@@ -19,8 +19,8 @@ discard block |
||
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 |
||
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 |
@@ -18,11 +18,11 @@ discard block |
||
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 |
||
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 | } |
@@ -30,7 +30,7 @@ |
||
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 | } |
@@ -54,7 +54,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | public function getIndex() { |
33 | 33 | $data = []; |
34 | 34 | $data['result'] = DB::table("cb_modules")->get(); |
35 | - return view($this->view.'.index',$data); |
|
35 | + return view($this->view.'.index', $data); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function getAdd() { |
39 | 39 | $data = []; |
40 | 40 | $data['tables'] = cb()->listAllTable(); |
41 | - $data['module'] = (request('modules_id'))?cb()->find("cb_modules", request("modules_id")):null; |
|
41 | + $data['module'] = (request('modules_id')) ?cb()->find("cb_modules", request("modules_id")) : null; |
|
42 | 42 | return view($this->view.'.add', $data); |
43 | 43 | } |
44 | 44 | |
@@ -51,17 +51,17 @@ discard block |
||
51 | 51 | $data = cb()->listAllColumns($table); |
52 | 52 | $pk = cb()->findPrimaryKey($table); |
53 | 53 | $result = []; |
54 | - foreach($data as $item) { |
|
54 | + foreach ($data as $item) { |
|
55 | 55 | |
56 | - if(Str::contains(strtolower($item),["title","name","label"])) { |
|
56 | + if (Str::contains(strtolower($item), ["title", "name", "label"])) { |
|
57 | 57 | $display = true; |
58 | - }else{ |
|
58 | + } else { |
|
59 | 59 | $display = false; |
60 | 60 | } |
61 | 61 | |
62 | 62 | $result[] = [ |
63 | 63 | "column"=>$item, |
64 | - "primary_key"=>($pk==$item)?true:false, |
|
64 | + "primary_key"=>($pk == $item) ?true:false, |
|
65 | 65 | "display"=>$display |
66 | 66 | ]; |
67 | 67 | } |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | |
71 | 71 | public function getColumns($table) |
72 | 72 | { |
73 | - if(request("modules_id")) { |
|
74 | - $module = cb()->find("cb_modules",request("modules_id")); |
|
75 | - if($module->last_column_build) { |
|
73 | + if (request("modules_id")) { |
|
74 | + $module = cb()->find("cb_modules", request("modules_id")); |
|
75 | + if ($module->last_column_build) { |
|
76 | 76 | return response()->json(json_decode($module->last_column_build)); |
77 | 77 | } |
78 | 78 | } |
@@ -80,56 +80,56 @@ discard block |
||
80 | 80 | $columns = cb()->listAllColumns($table); |
81 | 81 | $pk = cb()->findPrimaryKey($table); |
82 | 82 | $result = []; |
83 | - foreach($columns as $column) { |
|
84 | - if($column != $pk) { |
|
83 | + foreach ($columns as $column) { |
|
84 | + if ($column != $pk) { |
|
85 | 85 | |
86 | 86 | // Skip Column |
87 | - if($column == 'deleted_at') continue; |
|
87 | + if ($column == 'deleted_at') continue; |
|
88 | 88 | |
89 | 89 | // Check if any relation table candidate |
90 | 90 | $optionTable = ""; |
91 | - if(Str::substr(strtolower($column),-3,3) == "_id") { |
|
92 | - $relationTable = Str::substr($column,0,-3); |
|
93 | - if(Schema::hasTable($relationTable)) { |
|
91 | + if (Str::substr(strtolower($column), -3, 3) == "_id") { |
|
92 | + $relationTable = Str::substr($column, 0, -3); |
|
93 | + if (Schema::hasTable($relationTable)) { |
|
94 | 94 | $optionTable = $relationTable; |
95 | 95 | } |
96 | - }elseif (Str::substr(strtolower($column),0,3) == "id_") { |
|
97 | - $relationTable = Str::substr($column,3); |
|
98 | - if(Schema::hasTable($relationTable)) { |
|
96 | + }elseif (Str::substr(strtolower($column), 0, 3) == "id_") { |
|
97 | + $relationTable = Str::substr($column, 3); |
|
98 | + if (Schema::hasTable($relationTable)) { |
|
99 | 99 | $optionTable = $relationTable; |
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | - $label = trim(Str::title(str_replace(["id_","_id","_"]," ",$column))); |
|
103 | + $label = trim(Str::title(str_replace(["id_", "_id", "_"], " ", $column))); |
|
104 | 104 | $label = Str::singular($label); |
105 | 105 | $type = "text"; |
106 | 106 | |
107 | - if(Str::contains(strtolower($label),["photo","image","picture","gambar"])) { |
|
107 | + if (Str::contains(strtolower($label), ["photo", "image", "picture", "gambar"])) { |
|
108 | 108 | $type = "image"; |
109 | - }elseif (Str::contains(strtolower($label),["email","mail"])) { |
|
109 | + }elseif (Str::contains(strtolower($label), ["email", "mail"])) { |
|
110 | 110 | $type = "email"; |
111 | - }elseif (Str::contains(strtolower($label),["description","content","detail"])) { |
|
112 | - $type = "wysiwyg"; |
|
113 | - }elseif (Str::contains(strtolower($label),["price","money","grand_total","tax"])) { |
|
111 | + }elseif (Str::contains(strtolower($label), ["description", "content", "detail"])) { |
|
112 | + $type = "wysiwyg"; |
|
113 | + }elseif (Str::contains(strtolower($label), ["price", "money", "grand_total", "tax"])) { |
|
114 | 114 | $type = "money"; |
115 | - }elseif (Str::contains(strtolower($label),["quantity","qty","total","phone","telp"])) { |
|
115 | + }elseif (Str::contains(strtolower($label), ["quantity", "qty", "total", "phone", "telp"])) { |
|
116 | 116 | $type = "number"; |
117 | - }elseif (Str::contains(strtolower($label),["date"])) { |
|
117 | + }elseif (Str::contains(strtolower($label), ["date"])) { |
|
118 | 118 | $type = "date"; |
119 | 119 | } |
120 | 120 | |
121 | - if (Str::substr(strtolower($column),-3,3) == "_id") { |
|
121 | + if (Str::substr(strtolower($column), -3, 3) == "_id") { |
|
122 | 122 | $type = "select_table"; |
123 | 123 | } elseif (Str::substr($column, -3, 3) == "_at") { |
124 | 124 | $type = "datetime"; |
125 | - } elseif (Str::substr($column,0, 3) == "id_") { |
|
125 | + } elseif (Str::substr($column, 0, 3) == "id_") { |
|
126 | 126 | $type = "select_table"; |
127 | 127 | } |
128 | 128 | |
129 | 129 | $columnAdd = "on"; |
130 | 130 | $columnEdit = "on"; |
131 | 131 | $columnMandatory = "on"; |
132 | - if(in_array($column,['created_at','updated_at'])) { |
|
132 | + if (in_array($column, ['created_at', 'updated_at'])) { |
|
133 | 133 | $columnAdd = ""; |
134 | 134 | $columnEdit = ""; |
135 | 135 | $columnMandatory = ""; |
@@ -174,41 +174,41 @@ discard block |
||
174 | 174 | public function postCreateMigration() |
175 | 175 | { |
176 | 176 | try { |
177 | - cb()->validation(['table_name','structures']); |
|
177 | + cb()->validation(['table_name', 'structures']); |
|
178 | 178 | |
179 | 179 | $tableName = request("table_name"); |
180 | 180 | |
181 | - if(!Schema::hasTable($tableName)) { |
|
181 | + if (!Schema::hasTable($tableName)) { |
|
182 | 182 | $filenameMigration = date("Y_m_d_His")."_".$tableName.".php"; |
183 | 183 | $createTemplate = file_get_contents(base_path("vendor/laravel/framework/src/Illuminate/Database/Migrations/stubs/create.stub")); |
184 | 184 | $className = Str::studly($tableName); |
185 | 185 | $createTemplate = str_replace("DummyClass", $className, $createTemplate); |
186 | 186 | $createTemplate = str_replace("DummyTable", $tableName, $createTemplate); |
187 | - $createTemplate = str_replace("\$table->increments('id');","",$createTemplate); |
|
188 | - $createTemplate = str_replace("\$table->bigIncrements('id');","",$createTemplate); |
|
189 | - $createTemplate = str_replace("\$table->timestamps();","{structure}",$createTemplate); |
|
187 | + $createTemplate = str_replace("\$table->increments('id');", "", $createTemplate); |
|
188 | + $createTemplate = str_replace("\$table->bigIncrements('id');", "", $createTemplate); |
|
189 | + $createTemplate = str_replace("\$table->timestamps();", "{structure}", $createTemplate); |
|
190 | 190 | |
191 | 191 | $structureItems = ""; |
192 | 192 | |
193 | - if(request("timestamp")) { |
|
193 | + if (request("timestamp")) { |
|
194 | 194 | $structureItems .= "\$table->timestamps();\n\t\t\t"; |
195 | 195 | } |
196 | 196 | |
197 | - if(request("soft_deletes")) { |
|
197 | + if (request("soft_deletes")) { |
|
198 | 198 | $structureItems .= "\$table->softDeletes();\n\t\t\t"; |
199 | 199 | } |
200 | 200 | |
201 | - foreach(request("structures") as $item) { |
|
201 | + foreach (request("structures") as $item) { |
|
202 | 202 | |
203 | 203 | $nullable = ""; |
204 | 204 | |
205 | - if(!in_array($item['type_data'],["bigIncrements","increments","mediumIncrements","smallIncrements"])) { |
|
205 | + if (!in_array($item['type_data'], ["bigIncrements", "increments", "mediumIncrements", "smallIncrements"])) { |
|
206 | 206 | $nullable = "->nullable()"; |
207 | 207 | } |
208 | 208 | |
209 | - if($item['length']) { |
|
209 | + if ($item['length']) { |
|
210 | 210 | $structureItems .= "\$table->".$item['type_data']."('".$item['field_name']."', ".$item['length'].")$nullable;\n\t\t\t"; |
211 | - }else{ |
|
211 | + } else { |
|
212 | 212 | $structureItems .= "\$table->".$item['type_data']."('".$item['field_name']."')$nullable;\n\t\t\t"; |
213 | 213 | } |
214 | 214 | } |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | } |
228 | 228 | |
229 | 229 | } catch (CBValidationException $e) { |
230 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
230 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
231 | 231 | } catch (\Exception $e) { |
232 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
232 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
233 | 233 | } |
234 | 234 | |
235 | - return response()->json(['status'=>true,'message'=>'Migration successfully!']); |
|
235 | + return response()->json(['status'=>true, 'message'=>'Migration successfully!']); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | public function postCheckExistModule() |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | try { |
241 | 241 | cb()->validation(['name', 'table']); |
242 | 242 | |
243 | - if(DB::table("cb_modules")->where("table_name",request("table"))->where("name",request("name"))->count()) { |
|
243 | + if (DB::table("cb_modules")->where("table_name", request("table"))->where("name", request("name"))->count()) { |
|
244 | 244 | return response()->json(['status'=>true]); |
245 | 245 | } |
246 | 246 | |
247 | 247 | } catch (CBValidationException $e) { |
248 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
248 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | return response()->json(['status'=>false]); |
@@ -254,30 +254,30 @@ discard block |
||
254 | 254 | public function postAddSave() { |
255 | 255 | |
256 | 256 | try { |
257 | - cb()->validation(['name', 'table','icon','columns']); |
|
257 | + cb()->validation(['name', 'table', 'icon', 'columns']); |
|
258 | 258 | |
259 | 259 | $module = (new ModuleGenerator(request('table'), request('name'), request('icon'), request("columns"), request("rebuild")))->make(); |
260 | 260 | |
261 | 261 | } catch (CBValidationException $e) { |
262 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
262 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | return response()->json(['status'=>true, 'message'=>'Please remember that you can still modify the structure by edit the controller file '.$module['controller'].' :)']); |
266 | 266 | } |
267 | 267 | |
268 | 268 | public function getDelete($id) { |
269 | - $module = cb()->find("cb_modules",$id); |
|
269 | + $module = cb()->find("cb_modules", $id); |
|
270 | 270 | @unlink(app_path("Http/Controllers/".$module->controller.".php")); |
271 | 271 | DB::table("cb_modules")->where("id", $id)->delete(); |
272 | 272 | DB::table("cb_menus")->where("cb_modules_id", $id)->delete(); |
273 | - return cb()->redirectBack("The module has been deleted!","success"); |
|
273 | + return cb()->redirectBack("The module has been deleted!", "success"); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | public function getDeleteSoft($id) { |
277 | - $module = cb()->find("cb_modules",$id); |
|
277 | + $module = cb()->find("cb_modules", $id); |
|
278 | 278 | DB::table("cb_modules")->where("id", $id)->delete(); |
279 | 279 | DB::table("cb_menus")->where("cb_modules_id", $id)->delete(); |
280 | - return cb()->redirectBack("The module has been deleted!","success"); |
|
280 | + return cb()->redirectBack("The module has been deleted!", "success"); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | } |
284 | 284 | \ No newline at end of file |
@@ -112,15 +112,15 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -37,15 +37,15 @@ discard block |
||
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 |
||
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']; |
@@ -80,49 +80,49 @@ discard block |
||
80 | 80 | $moneyPrecision = $field['column_money_precision']; |
81 | 81 | $moneyThousandSeparator = $field['column_money_thousand_separator']; |
82 | 82 | $moneyDecimalSeparator = $field['column_money_decimal_separator']; |
83 | - $filterable = ($field['column_filterable']=="on")?"->filterable(true)":""; |
|
84 | - $foreign_key = (isset($field['column_foreign']))?"->foreignKey('".$field['column_foreign']."')":""; |
|
83 | + $filterable = ($field['column_filterable'] == "on") ? "->filterable(true)" : ""; |
|
84 | + $foreign_key = (isset($field['column_foreign'])) ? "->foreignKey('".$field['column_foreign']."')" : ""; |
|
85 | 85 | |
86 | 86 | // Additional Attributes |
87 | - $additional = $required . $indexShow . $detailShow . $addShow . $editShow . $help . $filterable . $foreign_key ; |
|
87 | + $additional = $required.$indexShow.$detailShow.$addShow.$editShow.$help.$filterable.$foreign_key; |
|
88 | 88 | |
89 | 89 | // Additional money |
90 | - $additional .= ($moneyPrefix && $field['column_type']=='money')?"->prefix('".$moneyPrefix."')":""; |
|
91 | - $additional .= ($moneyPrecision && $field['column_type']=='money')?"->precision('".$moneyPrecision."')":""; |
|
92 | - $additional .= ($moneyThousandSeparator && $field['column_type']=='money')?"->thousandSeparator('".$moneyThousandSeparator."')":""; |
|
93 | - $additional .= ($moneyDecimalSeparator && $field['column_type']=='money')?"->decimalSeparator('".$moneyDecimalSeparator."')":""; |
|
90 | + $additional .= ($moneyPrefix && $field['column_type'] == 'money') ? "->prefix('".$moneyPrefix."')" : ""; |
|
91 | + $additional .= ($moneyPrecision && $field['column_type'] == 'money') ? "->precision('".$moneyPrecision."')" : ""; |
|
92 | + $additional .= ($moneyThousandSeparator && $field['column_type'] == 'money') ? "->thousandSeparator('".$moneyThousandSeparator."')" : ""; |
|
93 | + $additional .= ($moneyDecimalSeparator && $field['column_type'] == 'money') ? "->decimalSeparator('".$moneyDecimalSeparator."')" : ""; |
|
94 | 94 | |
95 | 95 | // Additional for image & file type |
96 | - $additional .= ($fileEncrypt && in_array($field['column_type'],['file','image']))?"->encrypt(true)":""; |
|
97 | - $additional .= ($imageResizeWidth && in_array($field['column_type'],['file','image']))?"->resize(".$imageResizeWidth.",".$imageResizeHeight.")":""; |
|
96 | + $additional .= ($fileEncrypt && in_array($field['column_type'], ['file', 'image'])) ? "->encrypt(true)" : ""; |
|
97 | + $additional .= ($imageResizeWidth && in_array($field['column_type'], ['file', 'image'])) ? "->resize(".$imageResizeWidth.",".$imageResizeHeight.")" : ""; |
|
98 | 98 | |
99 | 99 | // Additional for date & datetime |
100 | - $additional .= ($dateFormat && in_array($field['column_type'],['date','datetime']))?"->format('".$dateFormat."')":""; |
|
100 | + $additional .= ($dateFormat && in_array($field['column_type'], ['date', 'datetime'])) ? "->format('".$dateFormat."')" : ""; |
|
101 | 101 | |
102 | 102 | // Additional for text |
103 | - $additional .= ($textDisplayLimit!="" && in_array($field['column_type'],['text','text_area','wysiwyg']))?"->strLimit(".$textDisplayLimit.")":""; |
|
104 | - $additional .= ($maxCharacter!="" && in_array($field['column_type'],['text','text_area']))?"->maxLength(".$maxCharacter.")":""; |
|
105 | - $additional .= ($minCharacter!="" && in_array($field['column_type'],['text','text_area']))?"->minLength(".$minCharacter.")":""; |
|
103 | + $additional .= ($textDisplayLimit != "" && in_array($field['column_type'], ['text', 'text_area', 'wysiwyg'])) ? "->strLimit(".$textDisplayLimit.")" : ""; |
|
104 | + $additional .= ($maxCharacter != "" && in_array($field['column_type'], ['text', 'text_area'])) ? "->maxLength(".$maxCharacter.")" : ""; |
|
105 | + $additional .= ($minCharacter != "" && in_array($field['column_type'], ['text', 'text_area'])) ? "->minLength(".$minCharacter.")" : ""; |
|
106 | 106 | |
107 | 107 | $methodName = Str::studly($field['column_type']); |
108 | - if($label && $column) { |
|
109 | - if(in_array($field['column_type'],['radio','select_option','checkbox'])) { |
|
110 | - if($options) { |
|
108 | + if ($label && $column) { |
|
109 | + if (in_array($field['column_type'], ['radio', 'select_option', 'checkbox'])) { |
|
110 | + if ($options) { |
|
111 | 111 | $optResult = []; |
112 | - foreach($options as $opt) { |
|
112 | + foreach ($options as $opt) { |
|
113 | 113 | $optResult[$opt['key']] = $opt['label']; |
114 | 114 | } |
115 | - $scaffold .= '$this->add' . $methodName . '("' . $label . '","' . $column . '")->options('.min_var_export($optResult).')' . $additional . ';' . "\n\t\t"; |
|
115 | + $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'")->options('.min_var_export($optResult).')'.$additional.';'."\n\t\t"; |
|
116 | 116 | } |
117 | - }elseif (in_array($field['column_type'],['radio_table','select_table'])) { |
|
117 | + }elseif (in_array($field['column_type'], ['radio_table', 'select_table'])) { |
|
118 | 118 | if ($optionTable && $optionValue && $optionDisplay) { |
119 | - $scaffold .= '$this->add' . $methodName . '("' . $label . '","' . $column . '",["table"=>"' . $optionTable . '","value_option"=>"' . $optionValue . '","display_option"=>"' . $optionDisplay . '","sql_condition"=>"' . $optionSqlCondition . '"])' . $additional . ';' . "\n\t\t"; |
|
119 | + $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'",["table"=>"'.$optionTable.'","value_option"=>"'.$optionValue.'","display_option"=>"'.$optionDisplay.'","sql_condition"=>"'.$optionSqlCondition.'"])'.$additional.';'."\n\t\t"; |
|
120 | 120 | } |
121 | 121 | }elseif ($field['column_type'] == "select_query") { |
122 | - if($sqlRawQuery && Str::contains($sqlRawQuery,["as `key`","as `label`"])) { |
|
123 | - $scaffold .= '$this->add' . $methodName . '("' . $label . '","' . $column . '","'.$sqlRawQuery.'")' . $additional . ';' . "\n\t\t"; |
|
122 | + if ($sqlRawQuery && Str::contains($sqlRawQuery, ["as `key`", "as `label`"])) { |
|
123 | + $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'","'.$sqlRawQuery.'")'.$additional.';'."\n\t\t"; |
|
124 | 124 | } |
125 | - }else{ |
|
125 | + } else { |
|
126 | 126 | $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'")'.$additional.';'."\n\t\t"; |
127 | 127 | } |
128 | 128 | } |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | $module['controller'] = $filename; |
146 | 146 | $module['last_column_build'] = json_encode($this->columns); |
147 | 147 | |
148 | - if($moduleData = DB::table("cb_modules")->where("name", $name)->where("table_name",$this->table)->first()) { |
|
149 | - DB::table("cb_modules")->where("id",$moduleData->id)->update($module); |
|
148 | + if ($moduleData = DB::table("cb_modules")->where("name", $name)->where("table_name", $this->table)->first()) { |
|
149 | + DB::table("cb_modules")->where("id", $moduleData->id)->update($module); |
|
150 | 150 | $id_modules = $moduleData->id; |
151 | - }else{ |
|
151 | + } else { |
|
152 | 152 | $id_modules = DB::table('cb_modules')->insertGetId($module); |
153 | 153 | } |
154 | 154 | |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | $menu['name'] = $module['name']; |
158 | 158 | $menu['type'] = 'module'; |
159 | 159 | $menu['cb_modules_id'] = $id_modules; |
160 | - if(isset($moduleData)) { |
|
161 | - DB::table("cb_menus")->where("cb_modules_id",$moduleData->id)->update($menu); |
|
162 | - }else{ |
|
160 | + if (isset($moduleData)) { |
|
161 | + DB::table("cb_menus")->where("cb_modules_id", $moduleData->id)->update($menu); |
|
162 | + } else { |
|
163 | 163 | DB::table('cb_menus')->insertGetId($menu); |
164 | 164 | } |
165 | 165 |
@@ -18,8 +18,8 @@ |
||
18 | 18 | public function handle($request, Closure $next) |
19 | 19 | { |
20 | 20 | |
21 | - if(session()->get("developer") != getSetting('developer_username')) { |
|
22 | - return cb()->redirect(cb()->getDeveloperUrl("login"),"Please login for first"); |
|
21 | + if (session()->get("developer") != getSetting('developer_username')) { |
|
22 | + return cb()->redirect(cb()->getDeveloperUrl("login"), "Please login for first"); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | return $next($request); |
@@ -25,15 +25,15 @@ |
||
25 | 25 | { |
26 | 26 | |
27 | 27 | try { |
28 | - if(@$this->command->option("password") == "AUTO" || !@$this->command->option("password")) { |
|
28 | + if (@$this->command->option("password") == "AUTO" || !@$this->command->option("password")) { |
|
29 | 29 | $password = Str::random(16); |
30 | - }else{ |
|
30 | + } else { |
|
31 | 31 | $password = $this->command->option("password"); |
32 | 32 | } |
33 | 33 | |
34 | - if(@$this->command->option("username") == "AUTO" || !@$this->command->option("username")) { |
|
34 | + if (@$this->command->option("username") == "AUTO" || !@$this->command->option("username")) { |
|
35 | 35 | $username = Str::random(5); |
36 | - }else{ |
|
36 | + } else { |
|
37 | 37 | $username = $this->command->option("username"); |
38 | 38 | } |
39 | 39 | } catch (\Exception $e) { |
@@ -27,13 +27,13 @@ |
||
27 | 27 | try { |
28 | 28 | if(@$this->command->option("password") == "AUTO" || !@$this->command->option("password")) { |
29 | 29 | $password = Str::random(16); |
30 | - }else{ |
|
30 | + } else{ |
|
31 | 31 | $password = $this->command->option("password"); |
32 | 32 | } |
33 | 33 | |
34 | 34 | if(@$this->command->option("username") == "AUTO" || !@$this->command->option("username")) { |
35 | 35 | $username = Str::random(5); |
36 | - }else{ |
|
36 | + } else{ |
|
37 | 37 | $username = $this->command->option("username"); |
38 | 38 | } |
39 | 39 | } catch (\Exception $e) { |
@@ -15,8 +15,11 @@ discard block |
||
15 | 15 | |
16 | 16 | public static function has($key) |
17 | 17 | { |
18 | - if(file_exists(app_path("CBPlugins/".$key))) return true; |
|
19 | - else return false; |
|
18 | + if(file_exists(app_path("CBPlugins/".$key))) { |
|
19 | + return true; |
|
20 | + } else { |
|
21 | + return false; |
|
22 | + } |
|
20 | 23 | } |
21 | 24 | |
22 | 25 | public static function isNeedUpgrade($pluginKey, $versionToCompare) |
@@ -24,7 +27,7 @@ discard block |
||
24 | 27 | $pluginJson = json_decode(file_get_contents(app_path("CBPlugins/".$pluginKey."/plugin.json")), true); |
25 | 28 | if($pluginJson) { |
26 | 29 | return version_compare($pluginJson['version'], $versionToCompare,"!="); |
27 | - }else{ |
|
30 | + } else{ |
|
28 | 31 | return false; |
29 | 32 | } |
30 | 33 | } |
@@ -15,26 +15,26 @@ discard block |
||
15 | 15 | |
16 | 16 | public static function has($key) |
17 | 17 | { |
18 | - if(file_exists(app_path("CBPlugins/".$key))) return true; |
|
18 | + if (file_exists(app_path("CBPlugins/".$key))) return true; |
|
19 | 19 | else return false; |
20 | 20 | } |
21 | 21 | |
22 | 22 | public static function isNeedUpgrade($pluginKey, $versionToCompare) |
23 | 23 | { |
24 | 24 | $pluginJson = json_decode(file_get_contents(app_path("CBPlugins/".$pluginKey."/plugin.json")), true); |
25 | - if($pluginJson) { |
|
26 | - return version_compare($pluginJson['version'], $versionToCompare,"!="); |
|
27 | - }else{ |
|
25 | + if ($pluginJson) { |
|
26 | + return version_compare($pluginJson['version'], $versionToCompare, "!="); |
|
27 | + } else { |
|
28 | 28 | return false; |
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | 32 | public static function registerDefaultRoute($dir) |
33 | 33 | { |
34 | - Route::group(['middleware' => ['web',\crocodicstudio\crudbooster\middlewares\CBDeveloper::class], |
|
34 | + Route::group(['middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBDeveloper::class], |
|
35 | 35 | 'prefix'=>"developer/".getSetting('developer_path'), |
36 | - 'namespace' => 'App\CBPlugins\\'.basename(dirname("./../".$dir)).'\Controllers'], function () use ($dir) { |
|
37 | - cb()->routeController("plugins/".basename(dirname("./../".$dir)),"\App\CBPlugins\\".basename(dirname("./../".$dir))."\Controllers\\".basename(dirname("./../".$dir))."Controller"); |
|
36 | + 'namespace' => 'App\CBPlugins\\'.basename(dirname("./../".$dir)).'\Controllers'], function() use ($dir) { |
|
37 | + cb()->routeController("plugins/".basename(dirname("./../".$dir)), "\App\CBPlugins\\".basename(dirname("./../".$dir))."\Controllers\\".basename(dirname("./../".$dir))."Controller"); |
|
38 | 38 | }); |
39 | 39 | } |
40 | 40 | |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | $plugins_from_master = $this->getAll(__DIR__."/../views/themes"); |
44 | 44 | $result = []; |
45 | 45 | $plugins = array_merge($plugins_from_master, $plugins_from_user); |
46 | - foreach($plugins as $plugin) { |
|
47 | - if($plugin['type'] == "theme") { |
|
46 | + foreach ($plugins as $plugin) { |
|
47 | + if ($plugin['type'] == "theme") { |
|
48 | 48 | $result[] = $plugin; |
49 | 49 | } |
50 | 50 | } |
@@ -53,15 +53,15 @@ discard block |
||
53 | 53 | |
54 | 54 | public function getAll($path = null) |
55 | 55 | { |
56 | - $path = ($path)?:app_path("CBPlugins"); |
|
56 | + $path = ($path) ?: app_path("CBPlugins"); |
|
57 | 57 | $plugins = scandir($path); |
58 | 58 | |
59 | 59 | $result = []; |
60 | - foreach($plugins as $plugin) { |
|
61 | - if($plugin != "." && $plugin != "..") { |
|
60 | + foreach ($plugins as $plugin) { |
|
61 | + if ($plugin != "." && $plugin != "..") { |
|
62 | 62 | $basename = basename($plugin); |
63 | 63 | $row = json_decode(file_get_contents($path.DIRECTORY_SEPARATOR.$plugin.DIRECTORY_SEPARATOR."plugin.json"), true); |
64 | - if($row) { |
|
64 | + if ($row) { |
|
65 | 65 | try { |
66 | 66 | $row['url'] = route($basename."ControllerGetIndex"); |
67 | 67 | } catch (\Exception $e) { |
@@ -18,7 +18,7 @@ |
||
18 | 18 | public function getIndex() { |
19 | 19 | $data = []; |
20 | 20 | $data['page_title'] = "Dashboard"; |
21 | - return view('crudbooster::dev_layouts.modules.dashboard',$data); |
|
21 | + return view('crudbooster::dev_layouts.modules.dashboard', $data); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function postSkipTutorial() |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | public function getIndex() { |
26 | 26 | $data = []; |
27 | - return view($this->view.".index",$data); |
|
27 | + return view($this->view.".index", $data); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function postSave() |
@@ -38,6 +38,6 @@ discard block |
||
38 | 38 | "MAIL_ENCRYPTION"=>request("MAIL_ENCRYPTION") |
39 | 39 | ]); |
40 | 40 | |
41 | - return cb()->redirectBack("Mail configuration has been updated!","success"); |
|
41 | + return cb()->redirectBack("Mail configuration has been updated!", "success"); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | \ No newline at end of file |