@@ -33,7 +33,9 @@ discard block |
||
33 | 33 | |
34 | 34 | public function getLogin() |
35 | 35 | { |
36 | - if(!auth()->guest()) return redirect(cb()->getAdminUrl()); |
|
36 | + if(!auth()->guest()) { |
|
37 | + return redirect(cb()->getAdminUrl()); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | cbHook()->hookGetLogin(); |
39 | 41 | |
@@ -43,7 +45,9 @@ discard block |
||
43 | 45 | public function postLogin() |
44 | 46 | { |
45 | 47 | try{ |
46 | - if($this->isSuspendedLogin()) throw new CBValidationException(cbLang("you_have_been_suspended")); |
|
48 | + if($this->isSuspendedLogin()) { |
|
49 | + throw new CBValidationException(cbLang("you_have_been_suspended")); |
|
50 | + } |
|
47 | 51 | |
48 | 52 | cb()->validation([ |
49 | 53 | 'email'=>'required|email', |
@@ -58,7 +62,7 @@ discard block |
||
58 | 62 | $this->incrementFailedLogin(); |
59 | 63 | return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'),'message_type'=>'warning']); |
60 | 64 | } |
61 | - }catch (CBValidationException $e) { |
|
65 | + } catch (CBValidationException $e) { |
|
62 | 66 | return cb()->redirect(cb()->getAdminUrl("login"),$e->getMessage(),'warning'); |
63 | 67 | } |
64 | 68 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | |
50 | 50 | if($err) { |
51 | 51 | return $err; |
52 | - }else { |
|
52 | + } else { |
|
53 | 53 | return $response; |
54 | 54 | } |
55 | 55 | } |
@@ -69,7 +69,7 @@ |
||
69 | 69 | return cb()->redirect(cb()->getAdminUrl("login"),"Thank you for register. Now you can login to start your session :)","success"); |
70 | 70 | } |
71 | 71 | |
72 | - }catch (CBValidationException $e) { |
|
72 | + } catch (CBValidationException $e) { |
|
73 | 73 | return cb()->redirectBack($e->getMessage()); |
74 | 74 | } |
75 | 75 |
@@ -58,7 +58,7 @@ |
||
58 | 58 | return cb()->redirectBack("Your email is not registered"); |
59 | 59 | } |
60 | 60 | |
61 | - }catch (CBValidationException $e) { |
|
61 | + } catch (CBValidationException $e) { |
|
62 | 62 | return cb()->redirectBack($e->getMessage()); |
63 | 63 | } catch (\Exception $e) { |
64 | 64 | Log::error($e); |
@@ -14,8 +14,12 @@ |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | public function getSubModule($subModuleKey) { |
17 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
18 | - if(!verifyReferalUrl()) return cb()->redirect(module()->url(),"It looks like your url is incorrect"); |
|
17 | + if(!module()->canBrowse()) { |
|
18 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
19 | + } |
|
20 | + if(!verifyReferalUrl()) { |
|
21 | + return cb()->redirect(module()->url(),"It looks like your url is incorrect"); |
|
22 | + } |
|
19 | 23 | |
20 | 24 | if($subModule = Cache::get("subModule".$subModuleKey)) { |
21 | 25 | $foreignKey = $subModule['foreignKey']; |
@@ -23,8 +23,11 @@ |
||
23 | 23 | |
24 | 24 | public function hasData($key) { |
25 | 25 | $data = $this->data; |
26 | - if(isset($data[$key])) return true; |
|
27 | - else return false; |
|
26 | + if(isset($data[$key])) { |
|
27 | + return true; |
|
28 | + } else { |
|
29 | + return false; |
|
30 | + } |
|
28 | 31 | } |
29 | 32 | |
30 | 33 | public function setData($key, $value): void |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | if($resize_width || $resize_height) { |
101 | 101 | $this->resizeImage($file, $file_path.'/'.$filename, $resize_width, $resize_height); |
102 | 102 | return $file_path.'/'.$filename; |
103 | - }else{ |
|
103 | + } else{ |
|
104 | 104 | if (Storage::putFileAs($file_path, $file, $filename, 'public')) { |
105 | 105 | return $file_path.'/'.$filename; |
106 | 106 | } else { |
107 | 107 | throw new \Exception("Something went wrong, file can't upload!"); |
108 | 108 | } |
109 | 109 | } |
110 | - }else{ |
|
110 | + } else{ |
|
111 | 111 | throw new \Exception("The file format is not allowed!"); |
112 | 112 | } |
113 | 113 | } |
@@ -129,10 +129,10 @@ discard block |
||
129 | 129 | if($filename && $ext) { |
130 | 130 | return $this->uploadFileProcess($filename, $ext, $fileData, $encrypt, $resize_width, $resize_height); |
131 | 131 | } |
132 | - }else { |
|
132 | + } else { |
|
133 | 133 | throw new \Exception("Mime type not found"); |
134 | 134 | } |
135 | - }else{ |
|
135 | + } else{ |
|
136 | 136 | throw new \Exception("Mime type not found"); |
137 | 137 | } |
138 | 138 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | } |
210 | 210 | |
211 | 211 | Storage::put($fullFilePath, $img, 'public'); |
212 | - }else{ |
|
212 | + } else{ |
|
213 | 213 | throw new \Exception("The file format is not allowed!"); |
214 | 214 | } |
215 | 215 | } |
@@ -233,7 +233,9 @@ discard block |
||
233 | 233 | { |
234 | 234 | if (is_array($id)) { |
235 | 235 | $idHash = md5("find".$table.serialize($id)); |
236 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
236 | + if(miscellanousSingleton()->hasData($idHash)) { |
|
237 | + return miscellanousSingleton()->getData($idHash); |
|
238 | + } |
|
237 | 239 | |
238 | 240 | $first = DB::table($table); |
239 | 241 | foreach ($id as $k => $v) { |
@@ -245,7 +247,9 @@ discard block |
||
245 | 247 | return $data; |
246 | 248 | } else { |
247 | 249 | $idHash = md5("find".$table.$id); |
248 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
250 | + if(miscellanousSingleton()->hasData($idHash)) { |
|
251 | + return miscellanousSingleton()->getData($idHash); |
|
252 | + } |
|
249 | 253 | |
250 | 254 | $pk = $this->pk($table); |
251 | 255 | $data = DB::table($table)->where($pk, $id)->first(); |
@@ -266,19 +270,25 @@ discard block |
||
266 | 270 | |
267 | 271 | if(is_array($conditionOrCallback)) { |
268 | 272 | $idHash = md5("findAll".$table.serialize($conditionOrCallback)); |
269 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
273 | + if(miscellanousSingleton()->hasData($idHash)) { |
|
274 | + return miscellanousSingleton()->getData($idHash); |
|
275 | + } |
|
270 | 276 | |
271 | 277 | $data = DB::table($table)->where($conditionOrCallback)->get(); |
272 | 278 | } elseif (is_callable($conditionOrCallback)) { |
273 | 279 | $idHash = "findAll".$table.spl_object_hash($conditionOrCallback); |
274 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
280 | + if(miscellanousSingleton()->hasData($idHash)) { |
|
281 | + return miscellanousSingleton()->getData($idHash); |
|
282 | + } |
|
275 | 283 | |
276 | 284 | $data = DB::table($table); |
277 | 285 | $data = call_user_func($conditionOrCallback, $data); |
278 | 286 | $data = $data->get(); |
279 | 287 | } else { |
280 | 288 | $idHash = md5("findAll".$table.$conditionOrCallback); |
281 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
289 | + if(miscellanousSingleton()->hasData($idHash)) { |
|
290 | + return miscellanousSingleton()->getData($idHash); |
|
291 | + } |
|
282 | 292 | |
283 | 293 | $data = DB::table($table); |
284 | 294 | if($conditionOrCallback) { |
@@ -297,7 +307,9 @@ discard block |
||
297 | 307 | public function listAllTable() |
298 | 308 | { |
299 | 309 | $idHash = md5("listAllTable"); |
300 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
310 | + if(miscellanousSingleton()->hasData($idHash)) { |
|
311 | + return miscellanousSingleton()->getData($idHash); |
|
312 | + } |
|
301 | 313 | $data = DB::connection()->getDoctrineSchemaManager()->listTableNames(); |
302 | 314 | miscellanousSingleton()->setData($idHash, $data); |
303 | 315 | return $data; |
@@ -306,7 +318,9 @@ discard block |
||
306 | 318 | public function listAllColumns($table) |
307 | 319 | { |
308 | 320 | $idHash = md5("listAllColumns".$table); |
309 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
321 | + if(miscellanousSingleton()->hasData($idHash)) { |
|
322 | + return miscellanousSingleton()->getData($idHash); |
|
323 | + } |
|
310 | 324 | $data = Schema::getColumnListing($table); |
311 | 325 | miscellanousSingleton()->setData($idHash, $data); |
312 | 326 | return $data; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | if(SchemaHelper::hasColumn($this->data['table'], $column->getField())) { |
48 | 48 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
49 | 49 | } |
50 | - }else{ |
|
50 | + } else{ |
|
51 | 51 | $query->addSelect($column->getField()); |
52 | 52 | } |
53 | 53 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $keyword = sanitizeXSS(request("q")); |
61 | 61 | if(isset($this->data['hook_search_query'])) { |
62 | 62 | $query = call_user_func($this->data['hook_search_query'], $query); |
63 | - }else{ |
|
63 | + } else{ |
|
64 | 64 | $query->where(function ($where) use ($columns, $keyword) { |
65 | 65 | /** |
66 | 66 | * @var $where Builder |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | { |
70 | 70 | if(strpos($column->getField(),".") === false) { |
71 | 71 | $field = $this->data['table'].'.'.$column->getField(); |
72 | - }else{ |
|
72 | + } else{ |
|
73 | 73 | $field = $column->getField(); |
74 | 74 | } |
75 | 75 | $where->orWhere($field, 'like', '%'.$keyword.'%'); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $query->orderBy(request('order_by'), request('order_sort')); |
112 | 112 | } |
113 | 113 | } |
114 | - }else{ |
|
114 | + } else{ |
|
115 | 115 | /* |
116 | 116 | * For default, query will be order by primary key as descending |
117 | 117 | */ |
@@ -2,8 +2,11 @@ discard block |
||
2 | 2 | if(!function_exists("isConfigCached")) { |
3 | 3 | function isConfigCached() |
4 | 4 | { |
5 | - if(env("APP_NAME")=="" || env("APP_NAME")==null) return true; |
|
6 | - else return false; |
|
5 | + if(env("APP_NAME")=="" || env("APP_NAME")==null) { |
|
6 | + return true; |
|
7 | + } else { |
|
8 | + return false; |
|
9 | + } |
|
7 | 10 | } |
8 | 11 | } |
9 | 12 | |
@@ -113,7 +116,9 @@ discard block |
||
113 | 116 | } |
114 | 117 | |
115 | 118 | $str = substr($str, 0, -1); |
116 | - if (!file_put_contents($envFile, $str)) return false; |
|
119 | + if (!file_put_contents($envFile, $str)) { |
|
120 | + return false; |
|
121 | + } |
|
117 | 122 | return true; |
118 | 123 | } |
119 | 124 | } |
@@ -316,7 +321,7 @@ discard block |
||
316 | 321 | $settings = file_get_contents(storage_path('.cbconfig')); |
317 | 322 | $settings = decrypt($settings); |
318 | 323 | $settings = unserialize($settings); |
319 | - }else{ |
|
324 | + } else{ |
|
320 | 325 | $settings = []; |
321 | 326 | } |
322 | 327 | |
@@ -341,14 +346,14 @@ discard block |
||
341 | 346 | $settings = file_get_contents(storage_path('.cbconfig')); |
342 | 347 | $settings = decrypt($settings); |
343 | 348 | $settings = unserialize($settings); |
344 | - }else{ |
|
349 | + } else{ |
|
345 | 350 | $settings = []; |
346 | 351 | } |
347 | 352 | |
348 | 353 | if(isset($settings[$key])) { |
349 | 354 | \Illuminate\Support\Facades\Cache::forever("setting_".$key, $settings[$key]); |
350 | 355 | return $settings[$key]?:$default; |
351 | - }else{ |
|
356 | + } else{ |
|
352 | 357 | return $default; |
353 | 358 | } |
354 | 359 | } |
@@ -434,7 +439,7 @@ discard block |
||
434 | 439 | $url = request($name); |
435 | 440 | if(filter_var($url, FILTER_VALIDATE_URL)) { |
436 | 441 | return $url; |
437 | - }else{ |
|
442 | + } else{ |
|
438 | 443 | return request()->url(); |
439 | 444 | } |
440 | 445 | } |
@@ -446,14 +451,14 @@ discard block |
||
446 | 451 | $response = request($name); |
447 | 452 | if(is_string($response)) { |
448 | 453 | $response = sanitizeXSS($response); |
449 | - }elseif (is_array($response)) { |
|
454 | + } elseif (is_array($response)) { |
|
450 | 455 | array_walk_recursive($response, function(&$response) { |
451 | 456 | $response = sanitizeXSS($response); |
452 | 457 | }); |
453 | 458 | } |
454 | 459 | |
455 | 460 | return $response; |
456 | - }else{ |
|
461 | + } else{ |
|
457 | 462 | return Request::get($name); |
458 | 463 | } |
459 | 464 | } |
@@ -463,11 +468,13 @@ discard block |
||
463 | 468 | function min_var_export($input) { |
464 | 469 | if(is_array($input)) { |
465 | 470 | $buffer = []; |
466 | - foreach($input as $key => $value) |
|
467 | - $buffer[] = var_export($key, true)."=>".min_var_export($value); |
|
471 | + foreach($input as $key => $value) { |
|
472 | + $buffer[] = var_export($key, true)."=>".min_var_export($value); |
|
473 | + } |
|
468 | 474 | return "[".implode(",",$buffer)."]"; |
469 | - } else |
|
470 | - return var_export($input, true); |
|
475 | + } else { |
|
476 | + return var_export($input, true); |
|
477 | + } |
|
471 | 478 | } |
472 | 479 | } |
473 | 480 | |
@@ -480,10 +487,11 @@ discard block |
||
480 | 487 | $objects = scandir($dir); |
481 | 488 | foreach ($objects as $object) { |
482 | 489 | if ($object != "." && $object != "..") { |
483 | - if (is_dir($dir."/".$object)) |
|
484 | - rrmdir($dir."/".$object); |
|
485 | - else |
|
486 | - unlink($dir."/".$object); |
|
490 | + if (is_dir($dir."/".$object)) { |
|
491 | + rrmdir($dir."/".$object); |
|
492 | + } else { |
|
493 | + unlink($dir."/".$object); |
|
494 | + } |
|
487 | 495 | } |
488 | 496 | } |
489 | 497 | rmdir($dir); |