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