@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace crocodicstudio\crudbooster\helpers; |
3 | 3 | |
4 | -class UserSession { |
|
4 | +class UserSession { |
|
5 | 5 | |
6 | 6 | public function user() |
7 | 7 | { |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | public function photo() |
22 | 22 | { |
23 | 23 | $user = $this->user(); |
24 | - return ($user->photo)?asset($user->photo):asset(dummyPhoto()); |
|
24 | + return ($user->photo) ?asset($user->photo) : asset(dummyPhoto()); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public function roleName() |
28 | 28 | { |
29 | 29 | $user = $this->user(); |
30 | 30 | $role = cb()->find("cb_roles", $user->cb_roles_id); |
31 | - if($role) return $role->name; |
|
31 | + if ($role) return $role->name; |
|
32 | 32 | else return null; |
33 | 33 | } |
34 | 34 |
@@ -28,8 +28,11 @@ |
||
28 | 28 | { |
29 | 29 | $user = $this->user(); |
30 | 30 | $role = cb()->find("cb_roles", $user->cb_roles_id); |
31 | - if($role) return $role->name; |
|
32 | - else return null; |
|
31 | + if($role) { |
|
32 | + return $role->name; |
|
33 | + } else { |
|
34 | + return null; |
|
35 | + } |
|
33 | 36 | } |
34 | 37 | |
35 | 38 | public function roleId() |
@@ -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(config('crudbooster.ADMIN_PATH').'/'.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; |
@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | public function getIndex() { |
12 | 12 | $data = []; |
13 | 13 | $data['page_title'] = 'Profile'; |
14 | - return view('crudbooster::profile',$data); |
|
14 | + return view('crudbooster::profile', $data); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | public function postUpdate() { |
18 | - validator(request()->all(),[ |
|
18 | + validator(request()->all(), [ |
|
19 | 19 | 'name'=>'required|max:255|min:3', |
20 | 20 | 'email'=>'required|email', |
21 | 21 | 'photo'=>'image', |
@@ -26,19 +26,19 @@ discard block |
||
26 | 26 | $data = []; |
27 | 27 | $data['name'] = request('name'); |
28 | 28 | $data['email'] = request('email'); |
29 | - if(request('password')) { |
|
29 | + if (request('password')) { |
|
30 | 30 | $data['password'] = Hash::make(request('password')); |
31 | 31 | } |
32 | - if(request()->hasFile('photo')) { |
|
32 | + if (request()->hasFile('photo')) { |
|
33 | 33 | $data['photo'] = cb()->uploadFile('photo', true, 200, 200); |
34 | 34 | } |
35 | 35 | DB::table("users")->where("id", auth()->id())->update($data); |
36 | - }catch (\Exception $e) { |
|
36 | + } catch (\Exception $e) { |
|
37 | 37 | Log::error($e); |
38 | - return cb()->redirectBack("Something went wrong!","warning"); |
|
38 | + return cb()->redirectBack("Something went wrong!", "warning"); |
|
39 | 39 | } |
40 | 40 | |
41 | - return cb()->redirectBack("The profile data has been updated!","success"); |
|
41 | + return cb()->redirectBack("The profile data has been updated!", "success"); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | } |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | |
26 | 26 | public function __call($method, $parameters) |
27 | 27 | { |
28 | - if($method == "getData") { |
|
28 | + if ($method == "getData") { |
|
29 | 29 | $key = $parameters[0]; |
30 | - if(isset($this->data[$key])) { |
|
30 | + if (isset($this->data[$key])) { |
|
31 | 31 | return $this->data[$key]; |
32 | - }else{ |
|
32 | + } else { |
|
33 | 33 | return null; |
34 | 34 | } |
35 | - }else{ |
|
35 | + } else { |
|
36 | 36 | return null; |
37 | 37 | } |
38 | 38 | } |
@@ -47,19 +47,19 @@ discard block |
||
47 | 47 | |
48 | 48 | $query->addSelect($this->data['table'].'.'.cb()->pk($this->data['table']).' as primary_key'); |
49 | 49 | |
50 | - if(isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) |
|
50 | + if (isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) |
|
51 | 51 | { |
52 | 52 | $query = call_user_func($this->data['hook_query_index'], $query); |
53 | 53 | } |
54 | 54 | |
55 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
56 | - if($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
55 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
56 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
57 | 57 | $query->whereNull($this->data['table'].'.deleted_at'); |
58 | 58 | } |
59 | 59 | |
60 | 60 | |
61 | - if(isset($joins)) { |
|
62 | - foreach($joins as $join) |
|
61 | + if (isset($joins)) { |
|
62 | + foreach ($joins as $join) |
|
63 | 63 | { |
64 | 64 | $query->join($join['target_table'], |
65 | 65 | $join['target_table_primary'], |
@@ -69,31 +69,31 @@ discard block |
||
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | - foreach($columns as $column) { |
|
72 | + foreach ($columns as $column) { |
|
73 | 73 | /** @var ColumnModel $column */ |
74 | - if(strpos($column->getField(),".") === false) { |
|
74 | + if (strpos($column->getField(), ".") === false) { |
|
75 | 75 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
76 | - }else{ |
|
76 | + } else { |
|
77 | 77 | $query->addSelect($column->getField()); |
78 | 78 | } |
79 | 79 | |
80 | 80 | $query = getTypeHook($column->getType())->query($query, $column); |
81 | 81 | } |
82 | 82 | |
83 | - if(request()->has('q')) |
|
83 | + if (request()->has('q')) |
|
84 | 84 | { |
85 | - if(isset($this->data['hook_search_query'])) { |
|
85 | + if (isset($this->data['hook_search_query'])) { |
|
86 | 86 | $query = call_user_func($this->data['hook_search_query'], $query); |
87 | - }else{ |
|
88 | - $query->where(function ($where) use ($columns) { |
|
87 | + } else { |
|
88 | + $query->where(function($where) use ($columns) { |
|
89 | 89 | /** |
90 | 90 | * @var $where Builder |
91 | 91 | */ |
92 | - foreach($columns as $column) |
|
92 | + foreach ($columns as $column) |
|
93 | 93 | { |
94 | - if(strpos($column->getField(),".") === false) { |
|
94 | + if (strpos($column->getField(), ".") === false) { |
|
95 | 95 | $field = $this->data['table'].'.'.$column->getField(); |
96 | - }else{ |
|
96 | + } else { |
|
97 | 97 | $field = $column->getField(); |
98 | 98 | } |
99 | 99 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -102,17 +102,17 @@ discard block |
||
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | - if(isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) { |
|
105 | + if (isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) { |
|
106 | 106 | $query = call_user_func($this->data['hook_query_index'], $query); |
107 | 107 | } |
108 | 108 | |
109 | 109 | |
110 | - if(request()->has(['order_by','order_sort'])) |
|
110 | + if (request()->has(['order_by', 'order_sort'])) |
|
111 | 111 | { |
112 | - if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
|
112 | + if (in_array(request('order_by'), columnSingleton()->getColumnNameOnly())) { |
|
113 | 113 | $query->orderBy(request('order_by'), request('order_sort')); |
114 | 114 | } |
115 | - }else{ |
|
115 | + } else { |
|
116 | 116 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
117 | 117 | } |
118 | 118 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | public function getIndex() |
123 | 123 | { |
124 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
124 | + if (!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
125 | 125 | |
126 | 126 | $query = $this->repository(); |
127 | 127 | $result = $query->paginate(20); |
@@ -136,51 +136,51 @@ discard block |
||
136 | 136 | */ |
137 | 137 | private function validation() |
138 | 138 | { |
139 | - if(isset($this->data['validation'])) { |
|
139 | + if (isset($this->data['validation'])) { |
|
140 | 140 | $validator = Validator::make(request()->all(), @$this->data['validation'], @$this->data['validation_messages']); |
141 | 141 | if ($validator->fails()) { |
142 | 142 | $message = $validator->messages(); |
143 | 143 | $message_all = $message->all(); |
144 | - throw new CBValidationException(implode(', ',$message_all)); |
|
144 | + throw new CBValidationException(implode(', ', $message_all)); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | 149 | public function getAdd() |
150 | 150 | { |
151 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
151 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
152 | 152 | |
153 | 153 | $data = []; |
154 | 154 | $data['page_title'] = $this->data['page_title'].' : Add'; |
155 | 155 | $data['action_url'] = module()->addSaveURL(); |
156 | - return view('crudbooster::module.form.form',array_merge($data, $this->data)); |
|
156 | + return view('crudbooster::module.form.form', array_merge($data, $this->data)); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | public function postAddSave() |
160 | 160 | { |
161 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
161 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
162 | 162 | |
163 | 163 | try { |
164 | 164 | $this->validation(); |
165 | 165 | columnSingleton()->valueAssignment(); |
166 | 166 | $data = columnSingleton()->getAssignmentData(); |
167 | 167 | |
168 | - if(Schema::hasColumn($this->data['table'], 'created_at')) { |
|
168 | + if (Schema::hasColumn($this->data['table'], 'created_at')) { |
|
169 | 169 | $data['created_at'] = date('Y-m-d H:i:s'); |
170 | 170 | } |
171 | 171 | |
172 | 172 | $id = DB::table($this->data['table'])->insertGetId($data); |
173 | 173 | |
174 | - if(isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
174 | + if (isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
175 | 175 | call_user_func($this->data['hook_after_insert'], $id); |
176 | 176 | } |
177 | 177 | |
178 | 178 | } catch (CBValidationException $e) { |
179 | 179 | Log::debug($e); |
180 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
180 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
181 | 181 | } catch (\Exception $e) { |
182 | 182 | Log::error($e); |
183 | - return cb()->redirectBack($e->getMessage(),'warning'); |
|
183 | + return cb()->redirectBack($e->getMessage(), 'warning'); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | if (request('submit') == trans('crudbooster.button_save_more')) { |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | |
193 | 193 | public function getEdit($id) |
194 | 194 | { |
195 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
195 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
196 | 196 | |
197 | 197 | $data = []; |
198 | 198 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -203,17 +203,17 @@ discard block |
||
203 | 203 | |
204 | 204 | public function postEditSave($id) |
205 | 205 | { |
206 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
206 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
207 | 207 | |
208 | 208 | try { |
209 | 209 | $this->validation(); |
210 | 210 | columnSingleton()->valueAssignment(); |
211 | 211 | $data = columnSingleton()->getAssignmentData(); |
212 | - if(Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
212 | + if (Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
213 | 213 | $data['updated_at'] = date('Y-m-d H:i:s'); |
214 | 214 | } |
215 | 215 | |
216 | - if(isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
216 | + if (isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
217 | 217 | call_user_func($this->data['hook_before_update'], $id); |
218 | 218 | } |
219 | 219 | |
@@ -221,16 +221,16 @@ discard block |
||
221 | 221 | ->where(cb()->pk($this->data['table']), $id) |
222 | 222 | ->update($data); |
223 | 223 | |
224 | - if(isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
224 | + if (isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
225 | 225 | call_user_func($this->data['hook_after_update'], $id); |
226 | 226 | } |
227 | 227 | |
228 | 228 | } catch (CBValidationException $e) { |
229 | 229 | Log::debug($e); |
230 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
230 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
231 | 231 | } catch (\Exception $e) { |
232 | 232 | Log::error($e); |
233 | - return cb()->redirectBack($e->getMessage(),'warning'); |
|
233 | + return cb()->redirectBack($e->getMessage(), 'warning'); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | |
@@ -243,15 +243,15 @@ discard block |
||
243 | 243 | |
244 | 244 | public function getDelete($id) |
245 | 245 | { |
246 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
246 | + if (!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
247 | 247 | |
248 | - if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
248 | + if (isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
249 | 249 | call_user_func($this->data['hook_before_delete'], $id); |
250 | 250 | } |
251 | 251 | |
252 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
252 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
253 | 253 | |
254 | - if ($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
254 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
255 | 255 | DB::table($this->data['table']) |
256 | 256 | ->where(getPrimaryKey($this->data['table']), $id) |
257 | 257 | ->update(['deleted_at' => date('Y-m-d H:i:s')]); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | ->delete(); |
262 | 262 | } |
263 | 263 | |
264 | - if(isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
264 | + if (isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
265 | 265 | call_user_func($this->data['hook_after_delete'], $id); |
266 | 266 | } |
267 | 267 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | |
271 | 271 | public function getDetail($id) |
272 | 272 | { |
273 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
273 | + if (!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
274 | 274 | |
275 | 275 | $data = []; |
276 | 276 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -280,21 +280,21 @@ discard block |
||
280 | 280 | |
281 | 281 | public function postUploadFile() |
282 | 282 | { |
283 | - if(auth()->guest()) return redirect(cb()->getLoginUrl()); |
|
283 | + if (auth()->guest()) return redirect(cb()->getLoginUrl()); |
|
284 | 284 | |
285 | 285 | $file = null; |
286 | 286 | try { |
287 | 287 | |
288 | 288 | cb()->validation([ |
289 | - 'userfile' => 'required|mimes:' . config('crudbooster.UPLOAD_TYPES') |
|
289 | + 'userfile' => 'required|mimes:'.config('crudbooster.UPLOAD_TYPES') |
|
290 | 290 | ]); |
291 | 291 | |
292 | 292 | $file = cb()->uploadFile('userfile', true); |
293 | 293 | |
294 | 294 | } catch (CBValidationException $e) { |
295 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
295 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
296 | 296 | } catch (\Exception $e) { |
297 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
297 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | return response()->json([ |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | $key = $parameters[0]; |
30 | 30 | if(isset($this->data[$key])) { |
31 | 31 | return $this->data[$key]; |
32 | - }else{ |
|
32 | + } else{ |
|
33 | 33 | return null; |
34 | 34 | } |
35 | - }else{ |
|
35 | + } else{ |
|
36 | 36 | return null; |
37 | 37 | } |
38 | 38 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | /** @var ColumnModel $column */ |
74 | 74 | if(strpos($column->getField(),".") === false) { |
75 | 75 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
76 | - }else{ |
|
76 | + } else{ |
|
77 | 77 | $query->addSelect($column->getField()); |
78 | 78 | } |
79 | 79 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | { |
85 | 85 | if(isset($this->data['hook_search_query'])) { |
86 | 86 | $query = call_user_func($this->data['hook_search_query'], $query); |
87 | - }else{ |
|
87 | + } else{ |
|
88 | 88 | $query->where(function ($where) use ($columns) { |
89 | 89 | /** |
90 | 90 | * @var $where Builder |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | { |
94 | 94 | if(strpos($column->getField(),".") === false) { |
95 | 95 | $field = $this->data['table'].'.'.$column->getField(); |
96 | - }else{ |
|
96 | + } else{ |
|
97 | 97 | $field = $column->getField(); |
98 | 98 | } |
99 | 99 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
113 | 113 | $query->orderBy(request('order_by'), request('order_sort')); |
114 | 114 | } |
115 | - }else{ |
|
115 | + } else{ |
|
116 | 116 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
117 | 117 | } |
118 | 118 | |
@@ -121,7 +121,9 @@ discard block |
||
121 | 121 | |
122 | 122 | public function getIndex() |
123 | 123 | { |
124 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
124 | + if(!module()->canBrowse()) { |
|
125 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
126 | + } |
|
125 | 127 | |
126 | 128 | $query = $this->repository(); |
127 | 129 | $result = $query->paginate(20); |
@@ -148,7 +150,9 @@ discard block |
||
148 | 150 | |
149 | 151 | public function getAdd() |
150 | 152 | { |
151 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
153 | + if(!module()->canCreate()) { |
|
154 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
155 | + } |
|
152 | 156 | |
153 | 157 | $data = []; |
154 | 158 | $data['page_title'] = $this->data['page_title'].' : Add'; |
@@ -158,7 +162,9 @@ discard block |
||
158 | 162 | |
159 | 163 | public function postAddSave() |
160 | 164 | { |
161 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
165 | + if(!module()->canCreate()) { |
|
166 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
167 | + } |
|
162 | 168 | |
163 | 169 | try { |
164 | 170 | $this->validation(); |
@@ -192,7 +198,9 @@ discard block |
||
192 | 198 | |
193 | 199 | public function getEdit($id) |
194 | 200 | { |
195 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
201 | + if(!module()->canUpdate()) { |
|
202 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
203 | + } |
|
196 | 204 | |
197 | 205 | $data = []; |
198 | 206 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -203,7 +211,9 @@ discard block |
||
203 | 211 | |
204 | 212 | public function postEditSave($id) |
205 | 213 | { |
206 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
214 | + if(!module()->canUpdate()) { |
|
215 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
216 | + } |
|
207 | 217 | |
208 | 218 | try { |
209 | 219 | $this->validation(); |
@@ -243,7 +253,9 @@ discard block |
||
243 | 253 | |
244 | 254 | public function getDelete($id) |
245 | 255 | { |
246 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
256 | + if(!module()->canDelete()) { |
|
257 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
258 | + } |
|
247 | 259 | |
248 | 260 | if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
249 | 261 | call_user_func($this->data['hook_before_delete'], $id); |
@@ -270,7 +282,9 @@ discard block |
||
270 | 282 | |
271 | 283 | public function getDetail($id) |
272 | 284 | { |
273 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
285 | + if(!module()->canRead()) { |
|
286 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
287 | + } |
|
274 | 288 | |
275 | 289 | $data = []; |
276 | 290 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -280,7 +294,9 @@ discard block |
||
280 | 294 | |
281 | 295 | public function postUploadFile() |
282 | 296 | { |
283 | - if(auth()->guest()) return redirect(cb()->getLoginUrl()); |
|
297 | + if(auth()->guest()) { |
|
298 | + return redirect(cb()->getLoginUrl()); |
|
299 | + } |
|
284 | 300 | |
285 | 301 | $file = null; |
286 | 302 | try { |