@@ -31,7 +31,7 @@ |
||
31 | 31 | |
32 | 32 | if(is_callable($query)) { |
33 | 33 | $result = call_user_func($query); |
34 | - }else{ |
|
34 | + } else{ |
|
35 | 35 | $result = DB::select(DB::raw($query)); |
36 | 36 | } |
37 | 37 |
@@ -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 | } |
@@ -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 |
@@ -92,14 +92,14 @@ discard block |
||
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 |
||
121 | 121 | if($filename && $ext) { |
122 | 122 | return $this->uploadFileProcess($filename, $ext, $fileData, $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 |
||
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 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $newLocation = $pathWithoutName.'/w_'.$width.'_h_'.$height.'_'.$basename; |
189 | 189 | if(Storage::exists($newLocation)) { |
190 | 190 | return asset($newLocation); |
191 | - }else{ |
|
191 | + } else{ |
|
192 | 192 | $img = Image::make(storage_path($path))->fit($width,$height); |
193 | 193 | $img->save(storage_path($newLocation),$quality); |
194 | 194 | return asset($newLocation); |
@@ -235,7 +235,7 @@ discard block |
||
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 | |
@@ -260,14 +260,14 @@ discard block |
||
260 | 260 | $settings = file_get_contents(storage_path('.cbconfig')); |
261 | 261 | $settings = decrypt($settings); |
262 | 262 | $settings = unserialize($settings); |
263 | - }else{ |
|
263 | + } else{ |
|
264 | 264 | $settings = []; |
265 | 265 | } |
266 | 266 | |
267 | 267 | if(isset($settings[$key])) { |
268 | 268 | \Illuminate\Support\Facades\Cache::put("setting_".$key, $settings[$key], 180); |
269 | 269 | return $settings[$key]?:$default; |
270 | - }else{ |
|
270 | + } else{ |
|
271 | 271 | return $default; |
272 | 272 | } |
273 | 273 | } |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | $url = request($name); |
354 | 354 | if(filter_var($url, FILTER_VALIDATE_URL)) { |
355 | 355 | return $url; |
356 | - }else{ |
|
356 | + } else{ |
|
357 | 357 | return request()->url(); |
358 | 358 | } |
359 | 359 | } |
@@ -365,14 +365,14 @@ discard block |
||
365 | 365 | $response = request($name); |
366 | 366 | if(is_string($response)) { |
367 | 367 | $response = sanitizeXSS($response); |
368 | - }elseif (is_array($response)) { |
|
368 | + } elseif (is_array($response)) { |
|
369 | 369 | array_walk_recursive($response, function(&$response) { |
370 | 370 | $response = sanitizeXSS($response); |
371 | 371 | }); |
372 | 372 | } |
373 | 373 | |
374 | 374 | return $response; |
375 | - }else{ |
|
375 | + } else{ |
|
376 | 376 | return Request::get($name); |
377 | 377 | } |
378 | 378 | } |
@@ -382,11 +382,13 @@ discard block |
||
382 | 382 | function min_var_export($input) { |
383 | 383 | if(is_array($input)) { |
384 | 384 | $buffer = []; |
385 | - foreach($input as $key => $value) |
|
386 | - $buffer[] = var_export($key, true)."=>".min_var_export($value); |
|
385 | + foreach($input as $key => $value) { |
|
386 | + $buffer[] = var_export($key, true)."=>".min_var_export($value); |
|
387 | + } |
|
387 | 388 | return "[".implode(",",$buffer)."]"; |
388 | - } else |
|
389 | - return var_export($input, true); |
|
389 | + } else { |
|
390 | + return var_export($input, true); |
|
391 | + } |
|
390 | 392 | } |
391 | 393 | } |
392 | 394 | |
@@ -399,10 +401,11 @@ discard block |
||
399 | 401 | $objects = scandir($dir); |
400 | 402 | foreach ($objects as $object) { |
401 | 403 | if ($object != "." && $object != "..") { |
402 | - if (is_dir($dir."/".$object)) |
|
403 | - rrmdir($dir."/".$object); |
|
404 | - else |
|
405 | - unlink($dir."/".$object); |
|
404 | + if (is_dir($dir."/".$object)) { |
|
405 | + rrmdir($dir."/".$object); |
|
406 | + } else { |
|
407 | + unlink($dir."/".$object); |
|
408 | + } |
|
406 | 409 | } |
407 | 410 | } |
408 | 411 | rmdir($dir); |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | $key = $parameters[0]; |
32 | 32 | if(isset($this->data[$key])) { |
33 | 33 | return $this->data[$key]; |
34 | - }else{ |
|
34 | + } else{ |
|
35 | 35 | return null; |
36 | 36 | } |
37 | - }else{ |
|
37 | + } else{ |
|
38 | 38 | return null; |
39 | 39 | } |
40 | 40 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if(Schema::hasColumn($this->data['table'], $column->getField())) { |
72 | 72 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
73 | 73 | } |
74 | - }else{ |
|
74 | + } else{ |
|
75 | 75 | $query->addSelect($column->getField()); |
76 | 76 | } |
77 | 77 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | { |
84 | 84 | if(isset($this->data['hook_search_query'])) { |
85 | 85 | $query = call_user_func($this->data['hook_search_query'], $query); |
86 | - }else{ |
|
86 | + } else{ |
|
87 | 87 | $query->where(function ($where) use ($columns) { |
88 | 88 | /** |
89 | 89 | * @var $where Builder |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | if(strpos($column->getField(),".") === false) { |
94 | 94 | $field = $this->data['table'].'.'.$column->getField(); |
95 | - }else{ |
|
95 | + } else{ |
|
96 | 96 | $field = $column->getField(); |
97 | 97 | } |
98 | 98 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
112 | 112 | $query->orderBy(request('order_by'), request('order_sort')); |
113 | 113 | } |
114 | - }else{ |
|
114 | + } else{ |
|
115 | 115 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
116 | 116 | } |
117 | 117 | |
@@ -120,7 +120,9 @@ discard block |
||
120 | 120 | |
121 | 121 | public function getIndex() |
122 | 122 | { |
123 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
123 | + if(!module()->canBrowse()) { |
|
124 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
125 | + } |
|
124 | 126 | |
125 | 127 | $query = $this->repository(); |
126 | 128 | $result = $query->paginate( request("limit")?:cbConfig("LIMIT_TABLE_DATA") ); |
@@ -147,7 +149,9 @@ discard block |
||
147 | 149 | |
148 | 150 | public function getAdd() |
149 | 151 | { |
150 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
152 | + if(!module()->canCreate()) { |
|
153 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
154 | + } |
|
151 | 155 | |
152 | 156 | $data = []; |
153 | 157 | $data['page_title'] = $this->data['page_title'].' : '.cbLang('add'); |
@@ -157,7 +161,9 @@ discard block |
||
157 | 161 | |
158 | 162 | public function postAddSave() |
159 | 163 | { |
160 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
164 | + if(!module()->canCreate()) { |
|
165 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
166 | + } |
|
161 | 167 | |
162 | 168 | try { |
163 | 169 | $this->validation(); |
@@ -202,7 +208,9 @@ discard block |
||
202 | 208 | |
203 | 209 | public function getEdit($id) |
204 | 210 | { |
205 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
211 | + if(!module()->canUpdate()) { |
|
212 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
213 | + } |
|
206 | 214 | |
207 | 215 | $data = []; |
208 | 216 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -213,7 +221,9 @@ discard block |
||
213 | 221 | |
214 | 222 | public function postEditSave($id) |
215 | 223 | { |
216 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
224 | + if(!module()->canUpdate()) { |
|
225 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
226 | + } |
|
217 | 227 | |
218 | 228 | try { |
219 | 229 | $this->validation(); |
@@ -257,7 +267,9 @@ discard block |
||
257 | 267 | |
258 | 268 | public function getDelete($id) |
259 | 269 | { |
260 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
270 | + if(!module()->canDelete()) { |
|
271 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
272 | + } |
|
261 | 273 | |
262 | 274 | if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
263 | 275 | call_user_func($this->data['hook_before_delete'], $id); |
@@ -284,7 +296,9 @@ discard block |
||
284 | 296 | |
285 | 297 | public function getDetail($id) |
286 | 298 | { |
287 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
299 | + if(!module()->canRead()) { |
|
300 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
301 | + } |
|
288 | 302 | |
289 | 303 | $data = []; |
290 | 304 | $data['row'] = $this->repository()->where($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), $id)->first(); |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | |
9 | 9 | public function getLogin() |
10 | 10 | { |
11 | - if(!auth()->guest()) return redirect(cb()->getAdminUrl()); |
|
11 | + if(!auth()->guest()) { |
|
12 | + return redirect(cb()->getAdminUrl()); |
|
13 | + } |
|
12 | 14 | |
13 | 15 | cbHook()->hookGetLogin(); |
14 | 16 | |
@@ -29,7 +31,7 @@ discard block |
||
29 | 31 | } else { |
30 | 32 | return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'),'message_type'=>'warning']); |
31 | 33 | } |
32 | - }catch (CBValidationException $e) { |
|
34 | + } catch (CBValidationException $e) { |
|
33 | 35 | return cb()->redirect(cb()->getAdminUrl("login"),$e->getMessage(),'warning'); |
34 | 36 | } |
35 | 37 | } |
@@ -58,11 +60,11 @@ discard block |
||
58 | 60 | |
59 | 61 | return redirect(cb()->getDeveloperUrl()); |
60 | 62 | |
61 | - }else{ |
|
63 | + } else{ |
|
62 | 64 | return cb()->redirectBack( cbLang("password_and_username_is_wrong")); |
63 | 65 | } |
64 | 66 | |
65 | - }catch (CBValidationException $e) { |
|
67 | + } catch (CBValidationException $e) { |
|
66 | 68 | return cb()->redirect(cb()->getLoginUrl(),$e->getMessage(),'warning'); |
67 | 69 | } |
68 | 70 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | DB::table("users")->where("id", auth()->id())->update($data); |
37 | - }catch (\Exception $e) { |
|
37 | + } catch (\Exception $e) { |
|
38 | 38 | Log::error($e); |
39 | 39 | return cb()->redirectBack("Something went wrong!","warning"); |
40 | 40 | } |
@@ -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) { |