@@ -48,7 +48,9 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | $str = substr($str, 0, -1); |
| 51 | - if (!file_put_contents($envFile, $str)) return false; |
|
| 51 | + if (!file_put_contents($envFile, $str)) { |
|
| 52 | + return false; |
|
| 53 | + } |
|
| 52 | 54 | return true; |
| 53 | 55 | } |
| 54 | 56 | } |
@@ -251,7 +253,7 @@ discard block |
||
| 251 | 253 | $settings = file_get_contents(storage_path('.cbconfig')); |
| 252 | 254 | $settings = decrypt($settings); |
| 253 | 255 | $settings = unserialize($settings); |
| 254 | - }else{ |
|
| 256 | + } else{ |
|
| 255 | 257 | $settings = []; |
| 256 | 258 | } |
| 257 | 259 | |
@@ -276,14 +278,14 @@ discard block |
||
| 276 | 278 | $settings = file_get_contents(storage_path('.cbconfig')); |
| 277 | 279 | $settings = decrypt($settings); |
| 278 | 280 | $settings = unserialize($settings); |
| 279 | - }else{ |
|
| 281 | + } else{ |
|
| 280 | 282 | $settings = []; |
| 281 | 283 | } |
| 282 | 284 | |
| 283 | 285 | if(isset($settings[$key])) { |
| 284 | 286 | \Illuminate\Support\Facades\Cache::forever("setting_".$key, $settings[$key]); |
| 285 | 287 | return $settings[$key]?:$default; |
| 286 | - }else{ |
|
| 288 | + } else{ |
|
| 287 | 289 | return $default; |
| 288 | 290 | } |
| 289 | 291 | } |
@@ -369,7 +371,7 @@ discard block |
||
| 369 | 371 | $url = request($name); |
| 370 | 372 | if(filter_var($url, FILTER_VALIDATE_URL)) { |
| 371 | 373 | return $url; |
| 372 | - }else{ |
|
| 374 | + } else{ |
|
| 373 | 375 | return request()->url(); |
| 374 | 376 | } |
| 375 | 377 | } |
@@ -381,14 +383,14 @@ discard block |
||
| 381 | 383 | $response = request($name); |
| 382 | 384 | if(is_string($response)) { |
| 383 | 385 | $response = sanitizeXSS($response); |
| 384 | - }elseif (is_array($response)) { |
|
| 386 | + } elseif (is_array($response)) { |
|
| 385 | 387 | array_walk_recursive($response, function(&$response) { |
| 386 | 388 | $response = sanitizeXSS($response); |
| 387 | 389 | }); |
| 388 | 390 | } |
| 389 | 391 | |
| 390 | 392 | return $response; |
| 391 | - }else{ |
|
| 393 | + } else{ |
|
| 392 | 394 | return Request::get($name); |
| 393 | 395 | } |
| 394 | 396 | } |
@@ -398,11 +400,13 @@ discard block |
||
| 398 | 400 | function min_var_export($input) { |
| 399 | 401 | if(is_array($input)) { |
| 400 | 402 | $buffer = []; |
| 401 | - foreach($input as $key => $value) |
|
| 402 | - $buffer[] = var_export($key, true)."=>".min_var_export($value); |
|
| 403 | + foreach($input as $key => $value) { |
|
| 404 | + $buffer[] = var_export($key, true)."=>".min_var_export($value); |
|
| 405 | + } |
|
| 403 | 406 | return "[".implode(",",$buffer)."]"; |
| 404 | - } else |
|
| 405 | - return var_export($input, true); |
|
| 407 | + } else { |
|
| 408 | + return var_export($input, true); |
|
| 409 | + } |
|
| 406 | 410 | } |
| 407 | 411 | } |
| 408 | 412 | |
@@ -415,10 +419,11 @@ discard block |
||
| 415 | 419 | $objects = scandir($dir); |
| 416 | 420 | foreach ($objects as $object) { |
| 417 | 421 | if ($object != "." && $object != "..") { |
| 418 | - if (is_dir($dir."/".$object)) |
|
| 419 | - rrmdir($dir."/".$object); |
|
| 420 | - else |
|
| 421 | - unlink($dir."/".$object); |
|
| 422 | + if (is_dir($dir."/".$object)) { |
|
| 423 | + rrmdir($dir."/".$object); |
|
| 424 | + } else { |
|
| 425 | + unlink($dir."/".$object); |
|
| 426 | + } |
|
| 422 | 427 | } |
| 423 | 428 | } |
| 424 | 429 | rmdir($dir); |
@@ -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']; |
@@ -32,7 +32,9 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | public function getIndex() |
| 34 | 34 | { |
| 35 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 35 | + if(!module()->canBrowse()) { |
|
| 36 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 37 | + } |
|
| 36 | 38 | |
| 37 | 39 | $query = $this->repository(); |
| 38 | 40 | $result = $query->paginate( request("limit")?:cbConfig("LIMIT_TABLE_DATA") ); |
@@ -43,7 +45,9 @@ discard block |
||
| 43 | 45 | |
| 44 | 46 | public function getAdd() |
| 45 | 47 | { |
| 46 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 48 | + if(!module()->canCreate()) { |
|
| 49 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 50 | + } |
|
| 47 | 51 | |
| 48 | 52 | $data = []; |
| 49 | 53 | $data['page_title'] = $this->data['page_title'].' : '.cbLang('add'); |
@@ -53,7 +57,9 @@ discard block |
||
| 53 | 57 | |
| 54 | 58 | public function postAddSave() |
| 55 | 59 | { |
| 56 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 60 | + if(!module()->canCreate()) { |
|
| 61 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 62 | + } |
|
| 57 | 63 | |
| 58 | 64 | try { |
| 59 | 65 | $this->validation(); |
@@ -102,7 +108,9 @@ discard block |
||
| 102 | 108 | |
| 103 | 109 | public function getEdit($id) |
| 104 | 110 | { |
| 105 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 111 | + if(!module()->canUpdate()) { |
|
| 112 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 113 | + } |
|
| 106 | 114 | |
| 107 | 115 | $data = []; |
| 108 | 116 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -113,7 +121,9 @@ discard block |
||
| 113 | 121 | |
| 114 | 122 | public function postEditSave($id) |
| 115 | 123 | { |
| 116 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 124 | + if(!module()->canUpdate()) { |
|
| 125 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 126 | + } |
|
| 117 | 127 | |
| 118 | 128 | try { |
| 119 | 129 | $this->validation(); |
@@ -162,7 +172,9 @@ discard block |
||
| 162 | 172 | |
| 163 | 173 | public function getDelete($id) |
| 164 | 174 | { |
| 165 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 175 | + if(!module()->canDelete()) { |
|
| 176 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 177 | + } |
|
| 166 | 178 | |
| 167 | 179 | if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
| 168 | 180 | call_user_func($this->data['hook_before_delete'], $id); |
@@ -189,7 +201,9 @@ discard block |
||
| 189 | 201 | |
| 190 | 202 | public function getDetail($id) |
| 191 | 203 | { |
| 192 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 204 | + if(!module()->canRead()) { |
|
| 205 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 206 | + } |
|
| 193 | 207 | |
| 194 | 208 | $data = []; |
| 195 | 209 | $data['row'] = $this->repository()->where($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), $id)->first(); |
@@ -212,10 +226,10 @@ discard block |
||
| 212 | 226 | $key = $parameters[0]; |
| 213 | 227 | if(isset($this->data[$key])) { |
| 214 | 228 | return $this->data[$key]; |
| 215 | - }else{ |
|
| 229 | + } else{ |
|
| 216 | 230 | return null; |
| 217 | 231 | } |
| 218 | - }else{ |
|
| 232 | + } else{ |
|
| 219 | 233 | return null; |
| 220 | 234 | } |
| 221 | 235 | } |
@@ -202,13 +202,13 @@ discard block |
||
| 202 | 202 | $parentPath = $this->getData("permalink"); |
| 203 | 203 | $parentTitle = $this->getData("page_title"); |
| 204 | 204 | $this->addActionButton($label,function($row) use ($label, $controllerName, $foreignKey, $additionalInfo, $parentPath, $parentTitle) { |
| 205 | - $actionParameters = [ |
|
| 206 | - "label"=>$label, |
|
| 207 | - "foreignKey"=>$foreignKey, |
|
| 208 | - "foreignValue"=>$row->primary_key, |
|
| 209 | - "parentPath"=>$parentPath, |
|
| 210 | - "parentTitle"=>$parentTitle |
|
| 211 | - ]; |
|
| 205 | + $actionParameters = [ |
|
| 206 | + "label"=>$label, |
|
| 207 | + "foreignKey"=>$foreignKey, |
|
| 208 | + "foreignValue"=>$row->primary_key, |
|
| 209 | + "parentPath"=>$parentPath, |
|
| 210 | + "parentTitle"=>$parentTitle |
|
| 211 | + ]; |
|
| 212 | 212 | |
| 213 | 213 | if(isset($additionalInfo) && is_callable($additionalInfo)) { |
| 214 | 214 | $additionalInfo = call_user_func($additionalInfo, $row); |
@@ -217,15 +217,15 @@ discard block |
||
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - $actionHash = md5(serialize($actionParameters)); |
|
| 221 | - $actionHashToken = Cache::get("subModule".$actionHash); |
|
| 222 | - if(!$actionHashToken) { |
|
| 223 | - $actionHashToken = Str::random(5); |
|
| 224 | - Cache::forever("subModule".$actionHash, $actionHashToken); |
|
| 225 | - Cache::forever("subModule".$actionHashToken, $actionParameters); |
|
| 226 | - } |
|
| 220 | + $actionHash = md5(serialize($actionParameters)); |
|
| 221 | + $actionHashToken = Cache::get("subModule".$actionHash); |
|
| 222 | + if(!$actionHashToken) { |
|
| 223 | + $actionHashToken = Str::random(5); |
|
| 224 | + Cache::forever("subModule".$actionHash, $actionHashToken); |
|
| 225 | + Cache::forever("subModule".$actionHashToken, $actionParameters); |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | - return action(class_basename($controllerName)."@getSubModule",['subModuleKey'=>$actionHashToken])."?ref=".makeReferalUrl($parentTitle); |
|
| 228 | + return action(class_basename($controllerName)."@getSubModule",['subModuleKey'=>$actionHashToken])."?ref=".makeReferalUrl($parentTitle); |
|
| 229 | 229 | }, $condition, $font, $color); |
| 230 | 230 | |
| 231 | 231 | } |
@@ -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 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | { |
| 60 | 60 | if(isset($this->data['hook_search_query'])) { |
| 61 | 61 | $query = call_user_func($this->data['hook_search_query'], $query); |
| 62 | - }else{ |
|
| 62 | + } else{ |
|
| 63 | 63 | $query->where(function ($where) use ($columns) { |
| 64 | 64 | /** |
| 65 | 65 | * @var $where Builder |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | { |
| 69 | 69 | if(strpos($column->getField(),".") === false) { |
| 70 | 70 | $field = $this->data['table'].'.'.$column->getField(); |
| 71 | - }else{ |
|
| 71 | + } else{ |
|
| 72 | 72 | $field = $column->getField(); |
| 73 | 73 | } |
| 74 | 74 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
| 94 | 94 | $query->orderBy(request('order_by'), request('order_sort')); |
| 95 | 95 | } |
| 96 | - }else{ |
|
| 96 | + } else{ |
|
| 97 | 97 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | $model->setIcon($menu->icon); |
| 29 | 29 | $model->setName($menu->name); |
| 30 | 30 | $model->setBasepath(basename($model->getUrl())); |
| 31 | - }elseif ($menu->type == "module") { |
|
| 31 | + } elseif ($menu->type == "module") { |
|
| 32 | 32 | $module = cb()->find("cb_modules", $menu->cb_modules_id); |
| 33 | 33 | $className = '\App\Http\Controllers\\'.$module->controller; |
| 34 | 34 | $controllerClass = new $className(); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $model->setIcon($module->icon); |
| 38 | 38 | $model->setName($module->name); |
| 39 | 39 | $model->setBasepath(config('crudbooster.ADMIN_PATH').'/'.basename($model->getUrl())); |
| 40 | - }elseif ($menu->type == "path") { |
|
| 40 | + } elseif ($menu->type == "path") { |
|
| 41 | 41 | $model->setUrl(cb()->getAdminUrl($menu->path)); |
| 42 | 42 | $model->setIcon($menu->icon); |
| 43 | 43 | $model->setName($menu->name); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | if(request()->is($model->getBasepath()."*")) { |
| 48 | 48 | $model->setIsActive(true); |
| 49 | - }else{ |
|
| 49 | + } else{ |
|
| 50 | 50 | $model->setIsActive(false); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $menus = DB::table("cb_menus"); |
| 58 | 58 | if($parent_id) { |
| 59 | 59 | $menus->where("parent_cb_menus_id",$parent_id); |
| 60 | - }else{ |
|
| 60 | + } else{ |
|
| 61 | 61 | $menus->whereNull("parent_cb_menus_id"); |
| 62 | 62 | } |
| 63 | 63 | return $menus->orderBy("sort_number","asc")->get(); |
@@ -81,33 +81,45 @@ discard block |
||
| 81 | 81 | public function all($withPrivilege = true) { |
| 82 | 82 | $roles_id = ($withPrivilege)?cb()->session()->roleId():null; |
| 83 | 83 | $idHash = "menuUser".$roles_id.auth()->id(); |
| 84 | - if($menu = CacheHelper::getItemInGroup($idHash,"sidebar_menu")) return $menu; |
|
| 84 | + if($menu = CacheHelper::getItemInGroup($idHash,"sidebar_menu")) { |
|
| 85 | + return $menu; |
|
| 86 | + } |
|
| 85 | 87 | |
| 86 | 88 | $menus = $this->loadData(); |
| 87 | 89 | $result = []; |
| 88 | 90 | $menus_active = false; |
| 89 | 91 | foreach($menus as $menu) { |
| 90 | 92 | |
| 91 | - if($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) continue; |
|
| 93 | + if($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) { |
|
| 94 | + continue; |
|
| 95 | + } |
|
| 92 | 96 | |
| 93 | 97 | $sidebarModel = $this->assignToModel($menu); |
| 94 | - if($sidebarModel->getisActive()) $menus_active = true; |
|
| 98 | + if($sidebarModel->getisActive()) { |
|
| 99 | + $menus_active = true; |
|
| 100 | + } |
|
| 95 | 101 | if($menus2 = $this->loadData($menu->id)) { |
| 96 | 102 | $sub1 = []; |
| 97 | 103 | $menus2_active = false; |
| 98 | 104 | foreach ($menus2 as $menu2) { |
| 99 | 105 | |
| 100 | - if($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) continue; |
|
| 106 | + if($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) { |
|
| 107 | + continue; |
|
| 108 | + } |
|
| 101 | 109 | |
| 102 | 110 | $sidebarModel2 = $this->assignToModel($menu2); |
| 103 | - if($sidebarModel2->getisActive()) $menus2_active = true; |
|
| 111 | + if($sidebarModel2->getisActive()) { |
|
| 112 | + $menus2_active = true; |
|
| 113 | + } |
|
| 104 | 114 | |
| 105 | 115 | if($menus3 = $this->loadData($menu2->id)) { |
| 106 | 116 | $sub2 = []; |
| 107 | 117 | $menus3_active = false; |
| 108 | 118 | foreach ($menus3 as $menu3) { |
| 109 | 119 | |
| 110 | - if($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) continue; |
|
| 120 | + if($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) { |
|
| 121 | + continue; |
|
| 122 | + } |
|
| 111 | 123 | |
| 112 | 124 | $sidebarModel3 = $this->assignToModel($menu3); |
| 113 | 125 | |
@@ -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; |
@@ -37,8 +37,8 @@ |
||
| 37 | 37 | $this->menu = (!$this->menu)?cb()->find("cb_menus",["type"=>"path","path"=>request()->segment(2)]):$this->menu; |
| 38 | 38 | if($this->menu) { |
| 39 | 39 | $this->privilege = cb()->find("cb_role_privileges",[ |
| 40 | - "cb_menus_id"=>$this->menu->id, |
|
| 41 | - "cb_roles_id"=>cb()->session()->roleId() |
|
| 40 | + "cb_menus_id"=>$this->menu->id, |
|
| 41 | + "cb_roles_id"=>cb()->session()->roleId() |
|
| 42 | 42 | ]); |
| 43 | 43 | } |
| 44 | 44 | } |