@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | /** @var ColumnModel $column */ |
| 45 | 45 | if($data_row) { |
| 46 | 46 | $value = $data_row->{ $column->getField() }; |
| 47 | - }else{ |
|
| 47 | + } else{ |
|
| 48 | 48 | $value = request($column->getName()); |
| 49 | 49 | } |
| 50 | 50 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | foreach($column->getValue() as $key=>$val) { |
| 139 | 139 | $data[$key] = $val; |
| 140 | 140 | } |
| 141 | - }else{ |
|
| 141 | + } else{ |
|
| 142 | 142 | $data[$column->getField()] = $column->getValue(); |
| 143 | 143 | } |
| 144 | 144 | } |
@@ -7,7 +7,9 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | public function getLogin() |
| 9 | 9 | { |
| 10 | - if(!auth()->guest()) return redirect(cb()->getAdminUrl()); |
|
| 10 | + if(!auth()->guest()) { |
|
| 11 | + return redirect(cb()->getAdminUrl()); |
|
| 12 | + } |
|
| 11 | 13 | |
| 12 | 14 | cbHook()->hookGetLogin(); |
| 13 | 15 | |
@@ -28,7 +30,7 @@ discard block |
||
| 28 | 30 | } else { |
| 29 | 31 | return redirect(cb()->getLoginUrl())->with(['message'=>__('crudbooster.alert_password_wrong'),'message_type'=>'warning']); |
| 30 | 32 | } |
| 31 | - }catch (CBValidationException $e) { |
|
| 33 | + } catch (CBValidationException $e) { |
|
| 32 | 34 | return cb()->redirect(cb()->getAdminUrl("login"),$e->getMessage(),'warning'); |
| 33 | 35 | } |
| 34 | 36 | } |
@@ -57,11 +59,11 @@ discard block |
||
| 57 | 59 | |
| 58 | 60 | return redirect(cb()->getDeveloperUrl()); |
| 59 | 61 | |
| 60 | - }else{ |
|
| 62 | + } else{ |
|
| 61 | 63 | return cb()->redirectBack("Username and or password is wrong!"); |
| 62 | 64 | } |
| 63 | 65 | |
| 64 | - }catch (CBValidationException $e) { |
|
| 66 | + } catch (CBValidationException $e) { |
|
| 65 | 67 | return cb()->redirect(cb()->getLoginUrl(),$e->getMessage(),'warning'); |
| 66 | 68 | } |
| 67 | 69 | } |
@@ -76,45 +76,60 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | public function canBrowse() { |
| 78 | 78 | if($this->privilege) { |
| 79 | - if($this->privilege->can_browse) return true; |
|
| 80 | - else return false; |
|
| 81 | - }else{ |
|
| 79 | + if($this->privilege->can_browse) { |
|
| 80 | + return true; |
|
| 81 | + } else { |
|
| 82 | + return false; |
|
| 83 | + } |
|
| 84 | + } else{ |
|
| 82 | 85 | return true; |
| 83 | 86 | } |
| 84 | 87 | } |
| 85 | 88 | |
| 86 | 89 | public function canCreate() { |
| 87 | 90 | if($this->privilege) { |
| 88 | - if($this->privilege->can_create) return true; |
|
| 89 | - else return false; |
|
| 90 | - }else{ |
|
| 91 | + if($this->privilege->can_create) { |
|
| 92 | + return true; |
|
| 93 | + } else { |
|
| 94 | + return false; |
|
| 95 | + } |
|
| 96 | + } else{ |
|
| 91 | 97 | return true; |
| 92 | 98 | } |
| 93 | 99 | } |
| 94 | 100 | |
| 95 | 101 | public function canRead() { |
| 96 | 102 | if($this->privilege) { |
| 97 | - if($this->privilege->can_read) return true; |
|
| 98 | - else return false; |
|
| 99 | - }else{ |
|
| 103 | + if($this->privilege->can_read) { |
|
| 104 | + return true; |
|
| 105 | + } else { |
|
| 106 | + return false; |
|
| 107 | + } |
|
| 108 | + } else{ |
|
| 100 | 109 | return true; |
| 101 | 110 | } |
| 102 | 111 | } |
| 103 | 112 | |
| 104 | 113 | public function canUpdate() { |
| 105 | 114 | if($this->privilege) { |
| 106 | - if($this->privilege->can_update) return true; |
|
| 107 | - else return false; |
|
| 108 | - }else{ |
|
| 115 | + if($this->privilege->can_update) { |
|
| 116 | + return true; |
|
| 117 | + } else { |
|
| 118 | + return false; |
|
| 119 | + } |
|
| 120 | + } else{ |
|
| 109 | 121 | return true; |
| 110 | 122 | } |
| 111 | 123 | } |
| 112 | 124 | |
| 113 | 125 | public function canDelete() { |
| 114 | 126 | if($this->privilege) { |
| 115 | - if($this->privilege->can_delete) return true; |
|
| 116 | - else return false; |
|
| 117 | - }else{ |
|
| 127 | + if($this->privilege->can_delete) { |
|
| 128 | + return true; |
|
| 129 | + } else { |
|
| 130 | + return false; |
|
| 131 | + } |
|
| 132 | + } else{ |
|
| 118 | 133 | return true; |
| 119 | 134 | } |
| 120 | 135 | } |
@@ -123,7 +138,7 @@ discard block |
||
| 123 | 138 | { |
| 124 | 139 | if($this->controller_class && method_exists($this->controller_class, 'getAdd')) { |
| 125 | 140 | return action($this->controller.'@getAdd'); |
| 126 | - }else{ |
|
| 141 | + } else{ |
|
| 127 | 142 | return null; |
| 128 | 143 | } |
| 129 | 144 | } |
@@ -132,7 +147,7 @@ discard block |
||
| 132 | 147 | { |
| 133 | 148 | if($this->controller_class && method_exists($this->controller_class, 'postAddSave')) { |
| 134 | 149 | return action($this->controller.'@postAddSave'); |
| 135 | - }else{ |
|
| 150 | + } else{ |
|
| 136 | 151 | return null; |
| 137 | 152 | } |
| 138 | 153 | } |
@@ -141,7 +156,7 @@ discard block |
||
| 141 | 156 | { |
| 142 | 157 | if($this->controller_class && method_exists($this->controller_class, 'getEdit')) { |
| 143 | 158 | return action($this->controller.'@getEdit',['id'=>$id]); |
| 144 | - }else{ |
|
| 159 | + } else{ |
|
| 145 | 160 | return null; |
| 146 | 161 | } |
| 147 | 162 | } |
@@ -150,7 +165,7 @@ discard block |
||
| 150 | 165 | { |
| 151 | 166 | if(method_exists($this->controller_class, 'postEditSave')) { |
| 152 | 167 | return action($this->controller.'@postEditSave',['id'=>$id]); |
| 153 | - }else{ |
|
| 168 | + } else{ |
|
| 154 | 169 | return null; |
| 155 | 170 | } |
| 156 | 171 | } |
@@ -159,7 +174,7 @@ discard block |
||
| 159 | 174 | { |
| 160 | 175 | if($this->controller_class && method_exists($this->controller_class, 'getDetail')) { |
| 161 | 176 | return action($this->controller.'@getDetail',['id'=>$id]); |
| 162 | - }else{ |
|
| 177 | + } else{ |
|
| 163 | 178 | return null; |
| 164 | 179 | } |
| 165 | 180 | } |
@@ -168,7 +183,7 @@ discard block |
||
| 168 | 183 | { |
| 169 | 184 | if($this->controller_class && method_exists($this->controller_class, 'getDelete')) { |
| 170 | 185 | return action($this->controller.'@getDelete',['id'=>$id]); |
| 171 | - }else{ |
|
| 186 | + } else{ |
|
| 172 | 187 | return null; |
| 173 | 188 | } |
| 174 | 189 | } |
@@ -177,7 +192,7 @@ discard block |
||
| 177 | 192 | { |
| 178 | 193 | if($this->controller_class && method_exists($this->controller_class, 'getIndex')) { |
| 179 | 194 | return trim(action($this->controller.'@getIndex').'/'.$path,'/'); |
| 180 | - }else{ |
|
| 195 | + } else{ |
|
| 181 | 196 | return null; |
| 182 | 197 | } |
| 183 | 198 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | $model->setIcon($menu->icon); |
| 28 | 28 | $model->setName($menu->name); |
| 29 | 29 | $model->setBasepath(basename($model->getUrl())); |
| 30 | - }elseif ($menu->type == "module") { |
|
| 30 | + } elseif ($menu->type == "module") { |
|
| 31 | 31 | $module = cb()->find("cb_modules", $menu->cb_modules_id); |
| 32 | 32 | $className = '\App\Http\Controllers\\'.$module->controller; |
| 33 | 33 | $controllerClass = new $className(); |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $model->setIcon($module->icon); |
| 37 | 37 | $model->setName($module->name); |
| 38 | 38 | $model->setBasepath(basename($model->getUrl())); |
| 39 | - }elseif ($menu->type == "path") { |
|
| 39 | + } elseif ($menu->type == "path") { |
|
| 40 | 40 | $model->setUrl(cb()->getAdminUrl($menu->path)); |
| 41 | 41 | $model->setIcon($menu->icon); |
| 42 | 42 | $model->setName($menu->name); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $menus = DB::table("cb_menus"); |
| 50 | 50 | if($parent_id) { |
| 51 | 51 | $menus->where("parent_cb_menus_id",$parent_id); |
| 52 | - }else{ |
|
| 52 | + } else{ |
|
| 53 | 53 | $menus->whereNull("parent_cb_menus_id"); |
| 54 | 54 | } |
| 55 | 55 | return $menus->orderBy("sort_number","asc")->get(); |
@@ -76,21 +76,27 @@ discard block |
||
| 76 | 76 | $result = []; |
| 77 | 77 | foreach($menus as $menu) { |
| 78 | 78 | |
| 79 | - if($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) continue; |
|
| 79 | + if($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) { |
|
| 80 | + continue; |
|
| 81 | + } |
|
| 80 | 82 | |
| 81 | 83 | $sidebarModel = $this->assignToModel($menu); |
| 82 | 84 | if($menus2 = $this->loadData($menu->id)) { |
| 83 | 85 | $sub1 = []; |
| 84 | 86 | foreach ($menus2 as $menu2) { |
| 85 | 87 | |
| 86 | - if($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) continue; |
|
| 88 | + if($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) { |
|
| 89 | + continue; |
|
| 90 | + } |
|
| 87 | 91 | |
| 88 | 92 | $sidebarModel2 = $this->assignToModel($menu2); |
| 89 | 93 | if($menus3 = $this->loadData($menu2->id)) { |
| 90 | 94 | $sub2 = []; |
| 91 | 95 | foreach ($menus3 as $menu3) { |
| 92 | 96 | |
| 93 | - if($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) continue; |
|
| 97 | + if($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) { |
|
| 98 | + continue; |
|
| 99 | + } |
|
| 94 | 100 | |
| 95 | 101 | $sidebarModel3 = $this->assignToModel($menu3); |
| 96 | 102 | $sub2[] = $sidebarModel3; |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | { |
| 23 | 23 | if($column->getFormat()) { |
| 24 | 24 | return date($column->getFormat(), strtotime($row->{$column->getField()})); |
| 25 | - }else{ |
|
| 25 | + } else{ |
|
| 26 | 26 | return $row->{$column->getField()}; |
| 27 | 27 | } |
| 28 | 28 | } |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | $data = DB::table($table); |
| 37 | 37 | if($SQLCondition && is_callable($SQLCondition)) { |
| 38 | 38 | $data = call_user_func($SQLCondition, $data); |
| 39 | - }elseif ($SQLCondition && is_string($SQLCondition)) { |
|
| 39 | + } elseif ($SQLCondition && is_string($SQLCondition)) { |
|
| 40 | 40 | $data->whereRaw($SQLCondition); |
| 41 | 41 | } |
| 42 | 42 | $data = $data->get(); |
@@ -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 ]; |
@@ -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 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | /** @var ColumnModel $column */ |
| 76 | 76 | if(strpos($column->getField(),".") === false) { |
| 77 | 77 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
| 78 | - }else{ |
|
| 78 | + } else{ |
|
| 79 | 79 | $query->addSelect($column->getField()); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | { |
| 87 | 87 | if(isset($this->data['hook_search_query'])) { |
| 88 | 88 | $query = call_user_func($this->data['hook_search_query'], $query); |
| 89 | - }else{ |
|
| 89 | + } else{ |
|
| 90 | 90 | $query->where(function ($where) use ($columns) { |
| 91 | 91 | /** |
| 92 | 92 | * @var $where Builder |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | { |
| 96 | 96 | if(strpos($column->getField(),".") === false) { |
| 97 | 97 | $field = $this->data['table'].'.'.$column->getField(); |
| 98 | - }else{ |
|
| 98 | + } else{ |
|
| 99 | 99 | $field = $column->getField(); |
| 100 | 100 | } |
| 101 | 101 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
| 115 | 115 | $query->orderBy(request('order_by'), request('order_sort')); |
| 116 | 116 | } |
| 117 | - }else{ |
|
| 117 | + } else{ |
|
| 118 | 118 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -123,7 +123,9 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | public function getIndex() |
| 125 | 125 | { |
| 126 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 126 | + if(!module()->canBrowse()) { |
|
| 127 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 128 | + } |
|
| 127 | 129 | |
| 128 | 130 | $query = $this->repository(); |
| 129 | 131 | $result = $query->paginate(20); |
@@ -149,7 +151,9 @@ discard block |
||
| 149 | 151 | |
| 150 | 152 | public function getAdd() |
| 151 | 153 | { |
| 152 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 154 | + if(!module()->canCreate()) { |
|
| 155 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 156 | + } |
|
| 153 | 157 | |
| 154 | 158 | $data = []; |
| 155 | 159 | $data['page_title'] = $this->data['page_title'].' : Add'; |
@@ -159,7 +163,9 @@ discard block |
||
| 159 | 163 | |
| 160 | 164 | public function postAddSave() |
| 161 | 165 | { |
| 162 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 166 | + if(!module()->canCreate()) { |
|
| 167 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 168 | + } |
|
| 163 | 169 | |
| 164 | 170 | try { |
| 165 | 171 | $this->validation(); |
@@ -193,7 +199,9 @@ discard block |
||
| 193 | 199 | |
| 194 | 200 | public function getEdit($id) |
| 195 | 201 | { |
| 196 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 202 | + if(!module()->canUpdate()) { |
|
| 203 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 204 | + } |
|
| 197 | 205 | |
| 198 | 206 | $data = []; |
| 199 | 207 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -204,7 +212,9 @@ discard block |
||
| 204 | 212 | |
| 205 | 213 | public function postEditSave($id) |
| 206 | 214 | { |
| 207 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 215 | + if(!module()->canUpdate()) { |
|
| 216 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 217 | + } |
|
| 208 | 218 | |
| 209 | 219 | try { |
| 210 | 220 | $this->validation(); |
@@ -244,7 +254,9 @@ discard block |
||
| 244 | 254 | |
| 245 | 255 | public function getDelete($id) |
| 246 | 256 | { |
| 247 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 257 | + if(!module()->canDelete()) { |
|
| 258 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 259 | + } |
|
| 248 | 260 | |
| 249 | 261 | if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
| 250 | 262 | call_user_func($this->data['hook_before_delete'], $id); |
@@ -271,7 +283,9 @@ discard block |
||
| 271 | 283 | |
| 272 | 284 | public function getDetail($id) |
| 273 | 285 | { |
| 274 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 286 | + if(!module()->canRead()) { |
|
| 287 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have access to this area"); |
|
| 288 | + } |
|
| 275 | 289 | |
| 276 | 290 | $data = []; |
| 277 | 291 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -281,7 +295,9 @@ discard block |
||
| 281 | 295 | |
| 282 | 296 | public function postUploadFile() |
| 283 | 297 | { |
| 284 | - if(auth()->guest()) return redirect(cb()->getLoginUrl()); |
|
| 298 | + if(auth()->guest()) { |
|
| 299 | + return redirect(cb()->getLoginUrl()); |
|
| 300 | + } |
|
| 285 | 301 | |
| 286 | 302 | $file = null; |
| 287 | 303 | try { |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | $data = DB::table($table); |
| 37 | 37 | if($SQLCondition && is_callable($SQLCondition)) { |
| 38 | 38 | $data = call_user_func($SQLCondition, $data); |
| 39 | - }elseif ($SQLCondition && is_string($SQLCondition)) { |
|
| 39 | + } elseif ($SQLCondition && is_string($SQLCondition)) { |
|
| 40 | 40 | $data->whereRaw($SQLCondition); |
| 41 | 41 | } |
| 42 | 42 | $data = $data->get(); |