@@ -32,11 +32,11 @@ |
||
| 32 | 32 | |
| 33 | 33 | return redirect(cb()->getDeveloperUrl()); |
| 34 | 34 | |
| 35 | - }else{ |
|
| 35 | + } else{ |
|
| 36 | 36 | return cb()->redirectBack( cbLang("password_and_username_is_wrong")); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - }catch (CBValidationException $e) { |
|
| 39 | + } catch (CBValidationException $e) { |
|
| 40 | 40 | return cb()->redirect(cb()->getLoginUrl(),$e->getMessage(),'warning'); |
| 41 | 41 | } |
| 42 | 42 | } |
@@ -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 | */ |