@@ -26,17 +26,17 @@ discard block |
||
| 26 | 26 | try { |
| 27 | 27 | $routeArray = request()->route()->getAction(); |
| 28 | 28 | $this->controller = class_basename($routeArray['controller']); |
| 29 | - $this->controller = strtok($this->controller,"@"); |
|
| 29 | + $this->controller = strtok($this->controller, "@"); |
|
| 30 | 30 | |
| 31 | 31 | $className = "\\".$routeArray["namespace"]."\\".$this->controller; |
| 32 | - if(class_exists($className)) { |
|
| 33 | - $this->module = cb()->find("cb_modules",["controller"=>$this->controller]); |
|
| 34 | - if($this->module) { |
|
| 32 | + if (class_exists($className)) { |
|
| 33 | + $this->module = cb()->find("cb_modules", ["controller"=>$this->controller]); |
|
| 34 | + if ($this->module) { |
|
| 35 | 35 | $this->controller_class = new $className(); |
| 36 | - $this->menu = cb()->find("cb_menus",["cb_modules_id"=>$this->module->id]); |
|
| 37 | - $this->menu = (!$this->menu)?cb()->find("cb_menus",["type"=>"path","path"=>request()->segment(2)]):$this->menu; |
|
| 38 | - if($this->menu) { |
|
| 39 | - $this->privilege = cb()->find("cb_role_privileges",[ |
|
| 36 | + $this->menu = cb()->find("cb_menus", ["cb_modules_id"=>$this->module->id]); |
|
| 37 | + $this->menu = (!$this->menu) ?cb()->find("cb_menus", ["type"=>"path", "path"=>request()->segment(2)]) : $this->menu; |
|
| 38 | + if ($this->menu) { |
|
| 39 | + $this->privilege = cb()->find("cb_role_privileges", [ |
|
| 40 | 40 | "cb_menus_id"=>$this->menu->id, |
| 41 | 41 | "cb_roles_id"=>cb()->session()->roleId() |
| 42 | 42 | ]); |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public function getData($key) { |
| 60 | - if($this->controller_class) { |
|
| 60 | + if ($this->controller_class) { |
|
| 61 | 61 | $value = $this->controller_class->getData($key); |
| 62 | - if(isset($value)) { |
|
| 62 | + if (isset($value)) { |
|
| 63 | 63 | return $value; |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -70,128 +70,128 @@ discard block |
||
| 70 | 70 | * @return CBController |
| 71 | 71 | */ |
| 72 | 72 | public function getController() { |
| 73 | - return ($this->controller_class)?$this->controller_class:null; |
|
| 73 | + return ($this->controller_class) ? $this->controller_class : null; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | public function getPageTitle() |
| 77 | 77 | { |
| 78 | - return ($this->controller_class)?$this->controller_class->getData("page_title")?:cb()->getAppName():null; |
|
| 78 | + return ($this->controller_class) ? $this->controller_class->getData("page_title") ?: cb()->getAppName() : null; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | public function getTable() |
| 82 | 82 | { |
| 83 | - return ($this->controller_class)?$this->controller_class->getData("table"):null; |
|
| 83 | + return ($this->controller_class) ? $this->controller_class->getData("table") : null; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | public function getPageIcon() |
| 87 | 87 | { |
| 88 | - return ($this->controller_class)?$this->controller_class->getData('page_icon')?:"fa fa-bars":null; |
|
| 88 | + return ($this->controller_class) ? $this->controller_class->getData('page_icon') ?: "fa fa-bars" : null; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | public function canBrowse() { |
| 92 | - if($this->privilege) { |
|
| 93 | - if($this->privilege->can_browse) return true; |
|
| 92 | + if ($this->privilege) { |
|
| 93 | + if ($this->privilege->can_browse) return true; |
|
| 94 | 94 | else return false; |
| 95 | - }else{ |
|
| 95 | + } else { |
|
| 96 | 96 | return true; |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | public function canCreate() { |
| 101 | - if($this->privilege) { |
|
| 102 | - if($this->privilege->can_create) return true; |
|
| 101 | + if ($this->privilege) { |
|
| 102 | + if ($this->privilege->can_create) return true; |
|
| 103 | 103 | else return false; |
| 104 | - }else{ |
|
| 104 | + } else { |
|
| 105 | 105 | return true; |
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | public function canRead() { |
| 110 | - if($this->privilege) { |
|
| 111 | - if($this->privilege->can_read) return true; |
|
| 110 | + if ($this->privilege) { |
|
| 111 | + if ($this->privilege->can_read) return true; |
|
| 112 | 112 | else return false; |
| 113 | - }else{ |
|
| 113 | + } else { |
|
| 114 | 114 | return true; |
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | public function canUpdate() { |
| 119 | - if($this->privilege) { |
|
| 120 | - if($this->privilege->can_update) return true; |
|
| 119 | + if ($this->privilege) { |
|
| 120 | + if ($this->privilege->can_update) return true; |
|
| 121 | 121 | else return false; |
| 122 | - }else{ |
|
| 122 | + } else { |
|
| 123 | 123 | return true; |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | public function canDelete() { |
| 128 | - if($this->privilege) { |
|
| 129 | - if($this->privilege->can_delete) return true; |
|
| 128 | + if ($this->privilege) { |
|
| 129 | + if ($this->privilege->can_delete) return true; |
|
| 130 | 130 | else return false; |
| 131 | - }else{ |
|
| 131 | + } else { |
|
| 132 | 132 | return true; |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | public function addURL() |
| 137 | 137 | { |
| 138 | - if($this->controller_class && method_exists($this->controller_class, 'getAdd')) { |
|
| 138 | + if ($this->controller_class && method_exists($this->controller_class, 'getAdd')) { |
|
| 139 | 139 | return action($this->controller.'@getAdd'); |
| 140 | - }else{ |
|
| 140 | + } else { |
|
| 141 | 141 | return null; |
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | public function addSaveURL() |
| 146 | 146 | { |
| 147 | - if($this->controller_class && method_exists($this->controller_class, 'postAddSave')) { |
|
| 147 | + if ($this->controller_class && method_exists($this->controller_class, 'postAddSave')) { |
|
| 148 | 148 | return action($this->controller.'@postAddSave'); |
| 149 | - }else{ |
|
| 149 | + } else { |
|
| 150 | 150 | return null; |
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | public function editURL($id = null) |
| 155 | 155 | { |
| 156 | - if($this->controller_class && method_exists($this->controller_class, 'getEdit')) { |
|
| 156 | + if ($this->controller_class && method_exists($this->controller_class, 'getEdit')) { |
|
| 157 | 157 | return action($this->controller.'@getEdit')."/".$id; |
| 158 | - }else{ |
|
| 158 | + } else { |
|
| 159 | 159 | return null; |
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | public function editSaveURL($id = null) |
| 164 | 164 | { |
| 165 | - if(method_exists($this->controller_class, 'postEditSave')) { |
|
| 165 | + if (method_exists($this->controller_class, 'postEditSave')) { |
|
| 166 | 166 | return action($this->controller.'@postEditSave')."/".$id; |
| 167 | - }else{ |
|
| 167 | + } else { |
|
| 168 | 168 | return null; |
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - public function detailURL($id=null) |
|
| 172 | + public function detailURL($id = null) |
|
| 173 | 173 | { |
| 174 | - if($this->controller_class && method_exists($this->controller_class, 'getDetail')) { |
|
| 174 | + if ($this->controller_class && method_exists($this->controller_class, 'getDetail')) { |
|
| 175 | 175 | return action($this->controller.'@getDetail')."/".$id; |
| 176 | - }else{ |
|
| 176 | + } else { |
|
| 177 | 177 | return null; |
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - public function deleteURL($id=null) |
|
| 181 | + public function deleteURL($id = null) |
|
| 182 | 182 | { |
| 183 | - if($this->controller_class && method_exists($this->controller_class, 'getDelete')) { |
|
| 183 | + if ($this->controller_class && method_exists($this->controller_class, 'getDelete')) { |
|
| 184 | 184 | return action($this->controller.'@getDelete')."/".$id; |
| 185 | - }else{ |
|
| 185 | + } else { |
|
| 186 | 186 | return null; |
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | public function url($path = null) |
| 191 | 191 | { |
| 192 | - if($this->controller_class && method_exists($this->controller_class, 'getIndex')) { |
|
| 193 | - return trim(action($this->controller.'@getIndex').'/'.$path,'/'); |
|
| 194 | - }else{ |
|
| 192 | + if ($this->controller_class && method_exists($this->controller_class, 'getIndex')) { |
|
| 193 | + return trim(action($this->controller.'@getIndex').'/'.$path, '/'); |
|
| 194 | + } else { |
|
| 195 | 195 | return null; |
| 196 | 196 | } |
| 197 | 197 | } |