@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | public function getIndex() { |
27 | 27 | $data = []; |
28 | 28 | $data['result'] = DB::table("cb_modules")->get(); |
29 | - return view($this->view.'.index',$data); |
|
29 | + return view($this->view.'.index', $data); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function getAdd() { |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | |
38 | 38 | public function postAddSave() { |
39 | 39 | try { |
40 | - cb()->validation(['name', 'table','icon']); |
|
40 | + cb()->validation(['name', 'table', 'icon']); |
|
41 | 41 | |
42 | 42 | (new ModuleGenerator(request('table'), request('name'), request('icon')))->make(); |
43 | 43 | |
44 | - return cb()->redirect(route("DeveloperModulesControllerGetIndex"),"New module has been created!","success"); |
|
44 | + return cb()->redirect(route("DeveloperModulesControllerGetIndex"), "New module has been created!", "success"); |
|
45 | 45 | |
46 | 46 | } catch (CBValidationException $e) { |
47 | 47 | return cb()->redirectBack($e->getMessage()); |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | try { |
59 | 59 | cb()->validation(['name', 'icon']); |
60 | 60 | |
61 | - cb()->updateCompact("cb_modules", $id, ['name','icon']); |
|
61 | + cb()->updateCompact("cb_modules", $id, ['name', 'icon']); |
|
62 | 62 | |
63 | - return cb()->redirect(route("DeveloperModulesControllerGetIndex"),"Module has been updated!","success"); |
|
63 | + return cb()->redirect(route("DeveloperModulesControllerGetIndex"), "Module has been updated!", "success"); |
|
64 | 64 | |
65 | 65 | } catch (CBValidationException $e) { |
66 | 66 | return cb()->redirectBack($e->getMessage()); |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | public function getDelete($id) { |
71 | - $module = cb()->find("cb_modules",$id); |
|
71 | + $module = cb()->find("cb_modules", $id); |
|
72 | 72 | @unlink(app_path("Http/Controllers/".$module->controller)); |
73 | 73 | DB::table("cb_modules")->where("id", $id)->delete(); |
74 | 74 | DB::table("cb_menus")->where("cb_modules_id", $id)->delete(); |
75 | 75 | |
76 | - return cb()->redirectBack("The module has been deleted!","success"); |
|
76 | + return cb()->redirectBack("The module has been deleted!", "success"); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | } |
80 | 80 | \ No newline at end of file |
@@ -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 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | public function getLogin() |
10 | 10 | { |
11 | - if(!auth()->guest()) return redirect(cb()->getAdminUrl()); |
|
11 | + if (!auth()->guest()) return redirect(cb()->getAdminUrl()); |
|
12 | 12 | |
13 | 13 | cbHook()->hookGetLogin(); |
14 | 14 | |
@@ -17,20 +17,20 @@ discard block |
||
17 | 17 | |
18 | 18 | public function postLogin() |
19 | 19 | { |
20 | - try{ |
|
20 | + try { |
|
21 | 21 | cb()->validation([ |
22 | 22 | 'email'=>'required|email', |
23 | 23 | 'password'=>'required' |
24 | 24 | ]); |
25 | - $credential = request()->only(['email','password']); |
|
25 | + $credential = request()->only(['email', 'password']); |
|
26 | 26 | if (auth()->attempt($credential)) { |
27 | 27 | cbHook()->hookPostLogin(); |
28 | 28 | return redirect(cb()->getAdminUrl()); |
29 | 29 | } else { |
30 | - return redirect(cb()->getLoginUrl())->with(['message'=>__('crudbooster.alert_password_wrong'),'message_type'=>'warning']); |
|
30 | + return redirect(cb()->getLoginUrl())->with(['message'=>__('crudbooster.alert_password_wrong'), 'message_type'=>'warning']); |
|
31 | 31 | } |
32 | - }catch (CBValidationException $e) { |
|
33 | - return cb()->redirect(cb()->getAdminUrl("login"),$e->getMessage(),'warning'); |
|
32 | + } catch (CBValidationException $e) { |
|
33 | + return cb()->redirect(cb()->getAdminUrl("login"), $e->getMessage(), 'warning'); |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
@@ -45,25 +45,25 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | public function postLoginDeveloper() { |
48 | - try{ |
|
48 | + try { |
|
49 | 49 | cb()->validation([ |
50 | 50 | 'username'=>'required', |
51 | 51 | 'password'=>'required' |
52 | 52 | ]); |
53 | 53 | |
54 | - if(request('username') == config('crudbooster.DEV_USERNAME') |
|
54 | + if (request('username') == config('crudbooster.DEV_USERNAME') |
|
55 | 55 | && request('password') == Cache::get("developer_password")) { |
56 | 56 | |
57 | 57 | session(['developer'=>1]); |
58 | 58 | |
59 | 59 | return redirect(cb()->getDeveloperUrl()); |
60 | 60 | |
61 | - }else{ |
|
61 | + } else { |
|
62 | 62 | return cb()->redirectBack("Username and or password is wrong!"); |
63 | 63 | } |
64 | 64 | |
65 | - }catch (CBValidationException $e) { |
|
66 | - return cb()->redirect(cb()->getLoginUrl(),$e->getMessage(),'warning'); |
|
65 | + } catch (CBValidationException $e) { |
|
66 | + return cb()->redirect(cb()->getLoginUrl(), $e->getMessage(), 'warning'); |
|
67 | 67 | } |
68 | 68 | } |
69 | 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 | } |
@@ -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,135 +53,135 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | public function getData($key) { |
56 | - return ($this->controller_class)?$this->controller_class->getData($key)?:cb()->getAppName():null; |
|
56 | + return ($this->controller_class) ? $this->controller_class->getData($key) ?: cb()->getAppName() : null; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
60 | 60 | * @return CBController |
61 | 61 | */ |
62 | 62 | public function getController() { |
63 | - return ($this->controller_class)?$this->controller_class:null; |
|
63 | + return ($this->controller_class) ? $this->controller_class : null; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | public function getPageTitle() |
67 | 67 | { |
68 | - return ($this->controller_class)?$this->controller_class->getData("page_title")?:cb()->getAppName():null; |
|
68 | + return ($this->controller_class) ? $this->controller_class->getData("page_title") ?: cb()->getAppName() : null; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | public function getTable() |
72 | 72 | { |
73 | - return ($this->controller_class)?$this->controller_class->getData("table"):null; |
|
73 | + return ($this->controller_class) ? $this->controller_class->getData("table") : null; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | public function getPageIcon() |
77 | 77 | { |
78 | - return ($this->controller_class)?$this->controller_class->getData('page_icon')?:"fa fa-bars":null; |
|
78 | + return ($this->controller_class) ? $this->controller_class->getData('page_icon') ?: "fa fa-bars" : null; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | public function canBrowse() { |
82 | - if($this->privilege) { |
|
83 | - if($this->privilege->can_browse) return true; |
|
82 | + if ($this->privilege) { |
|
83 | + if ($this->privilege->can_browse) return true; |
|
84 | 84 | else return false; |
85 | - }else{ |
|
85 | + } else { |
|
86 | 86 | return true; |
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | 90 | public function canCreate() { |
91 | - if($this->privilege) { |
|
92 | - if($this->privilege->can_create) return true; |
|
91 | + if ($this->privilege) { |
|
92 | + if ($this->privilege->can_create) return true; |
|
93 | 93 | else return false; |
94 | - }else{ |
|
94 | + } else { |
|
95 | 95 | return true; |
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | 99 | public function canRead() { |
100 | - if($this->privilege) { |
|
101 | - if($this->privilege->can_read) return true; |
|
100 | + if ($this->privilege) { |
|
101 | + if ($this->privilege->can_read) return true; |
|
102 | 102 | else return false; |
103 | - }else{ |
|
103 | + } else { |
|
104 | 104 | return true; |
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | 108 | public function canUpdate() { |
109 | - if($this->privilege) { |
|
110 | - if($this->privilege->can_update) return true; |
|
109 | + if ($this->privilege) { |
|
110 | + if ($this->privilege->can_update) return true; |
|
111 | 111 | else return false; |
112 | - }else{ |
|
112 | + } else { |
|
113 | 113 | return true; |
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | 117 | public function canDelete() { |
118 | - if($this->privilege) { |
|
119 | - if($this->privilege->can_delete) return true; |
|
118 | + if ($this->privilege) { |
|
119 | + if ($this->privilege->can_delete) return true; |
|
120 | 120 | else return false; |
121 | - }else{ |
|
121 | + } else { |
|
122 | 122 | return true; |
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | 126 | public function addURL() |
127 | 127 | { |
128 | - if($this->controller_class && method_exists($this->controller_class, 'getAdd')) { |
|
128 | + if ($this->controller_class && method_exists($this->controller_class, 'getAdd')) { |
|
129 | 129 | return action($this->controller.'@getAdd'); |
130 | - }else{ |
|
130 | + } else { |
|
131 | 131 | return null; |
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | 135 | public function addSaveURL() |
136 | 136 | { |
137 | - if($this->controller_class && method_exists($this->controller_class, 'postAddSave')) { |
|
137 | + if ($this->controller_class && method_exists($this->controller_class, 'postAddSave')) { |
|
138 | 138 | return action($this->controller.'@postAddSave'); |
139 | - }else{ |
|
139 | + } else { |
|
140 | 140 | return null; |
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
144 | 144 | public function editURL($id = null) |
145 | 145 | { |
146 | - if($this->controller_class && method_exists($this->controller_class, 'getEdit')) { |
|
147 | - return action($this->controller.'@getEdit',['id'=>$id]); |
|
148 | - }else{ |
|
146 | + if ($this->controller_class && method_exists($this->controller_class, 'getEdit')) { |
|
147 | + return action($this->controller.'@getEdit', ['id'=>$id]); |
|
148 | + } else { |
|
149 | 149 | return null; |
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | 153 | public function editSaveURL($id = null) |
154 | 154 | { |
155 | - if(method_exists($this->controller_class, 'postEditSave')) { |
|
156 | - return action($this->controller.'@postEditSave',['id'=>$id]); |
|
157 | - }else{ |
|
155 | + if (method_exists($this->controller_class, 'postEditSave')) { |
|
156 | + return action($this->controller.'@postEditSave', ['id'=>$id]); |
|
157 | + } else { |
|
158 | 158 | return null; |
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | - public function detailURL($id=null) |
|
162 | + public function detailURL($id = null) |
|
163 | 163 | { |
164 | - if($this->controller_class && method_exists($this->controller_class, 'getDetail')) { |
|
165 | - return action($this->controller.'@getDetail',['id'=>$id]); |
|
166 | - }else{ |
|
164 | + if ($this->controller_class && method_exists($this->controller_class, 'getDetail')) { |
|
165 | + return action($this->controller.'@getDetail', ['id'=>$id]); |
|
166 | + } else { |
|
167 | 167 | return null; |
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
171 | - public function deleteURL($id=null) |
|
171 | + public function deleteURL($id = null) |
|
172 | 172 | { |
173 | - if($this->controller_class && method_exists($this->controller_class, 'getDelete')) { |
|
174 | - return action($this->controller.'@getDelete',['id'=>$id]); |
|
175 | - }else{ |
|
173 | + if ($this->controller_class && method_exists($this->controller_class, 'getDelete')) { |
|
174 | + return action($this->controller.'@getDelete', ['id'=>$id]); |
|
175 | + } else { |
|
176 | 176 | return null; |
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | 180 | public function url($path = null) |
181 | 181 | { |
182 | - if($this->controller_class && method_exists($this->controller_class, 'getIndex')) { |
|
183 | - return trim(action($this->controller.'@getIndex').'/'.$path,'/'); |
|
184 | - }else{ |
|
182 | + if ($this->controller_class && method_exists($this->controller_class, 'getIndex')) { |
|
183 | + return trim(action($this->controller.'@getIndex').'/'.$path, '/'); |
|
184 | + } else { |
|
185 | 185 | return null; |
186 | 186 | } |
187 | 187 | } |
@@ -20,9 +20,9 @@ |
||
20 | 20 | */ |
21 | 21 | public function indexRender($row, $column) |
22 | 22 | { |
23 | - if($column->getFormat()) { |
|
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 | } |
@@ -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 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function optionsFromTable($table, $key_field, $display_field, $SQLCondition = null) { |
36 | 36 | $data = DB::table($table); |
37 | - if($SQLCondition && is_callable($SQLCondition)) { |
|
37 | + if ($SQLCondition && is_callable($SQLCondition)) { |
|
38 | 38 | $data = call_user_func($SQLCondition, $data); |
39 | 39 | }elseif ($SQLCondition && is_string($SQLCondition)) { |
40 | 40 | $data->whereRaw($SQLCondition); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $data = $data->get(); |
43 | 43 | $options = []; |
44 | 44 | foreach ($data as $d) { |
45 | - $options[ $d->$key_field ] = $d->$display_field; |
|
45 | + $options[$d->$key_field] = $d->$display_field; |
|
46 | 46 | } |
47 | 47 | $this->options($options); |
48 | 48 | } |
@@ -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(); |
@@ -19,9 +19,9 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public function query($query, $column) |
21 | 21 | { |
22 | - if($column->getOptionsFromTable()) { |
|
22 | + if ($column->getOptionsFromTable()) { |
|
23 | 23 | $option = $column->getOptionsFromTable(); |
24 | - $query->join($option["table"],$option["table"].'.'.$option["key_field"],"=", $column->getName()); |
|
24 | + $query->join($option["table"], $option["table"].'.'.$option["key_field"], "=", $column->getName()); |
|
25 | 25 | $query->addSelect($option['table'].'.'.$option['display_field'].' as '.$option['table'].'_'.$option['display_field']); |
26 | 26 | } |
27 | 27 | return $query; |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function indexRender($row, $column) |
35 | 35 | { |
36 | - if($column->getOptionsFromTable()) { |
|
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 | - return @$option[ $key ]; |
|
42 | + return @$option[$key]; |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 |
@@ -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 ]; |
@@ -12,7 +12,7 @@ |
||
12 | 12 | */ |
13 | 13 | public function up() |
14 | 14 | { |
15 | - Schema::create('cb_menus', function (Blueprint $table) { |
|
15 | + Schema::create('cb_menus', function(Blueprint $table) { |
|
16 | 16 | $table->increments("id"); |
17 | 17 | $table->string('name'); |
18 | 18 | $table->string("icon")->nullable(); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function optionsFromTable($table, $key_field, $display_field, $SQLCondition = null) { |
36 | 36 | $data = DB::table($table); |
37 | - if($SQLCondition && is_callable($SQLCondition)) { |
|
37 | + if ($SQLCondition && is_callable($SQLCondition)) { |
|
38 | 38 | $data = call_user_func($SQLCondition, $data); |
39 | 39 | }elseif ($SQLCondition && is_string($SQLCondition)) { |
40 | 40 | $data->whereRaw($SQLCondition); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $data = $data->get(); |
43 | 43 | $options = []; |
44 | 44 | foreach ($data as $d) { |
45 | - $options[ $d->$key_field ] = $d->$display_field; |
|
45 | + $options[$d->$key_field] = $d->$display_field; |
|
46 | 46 | } |
47 | 47 | $this->options($options); |
48 | 48 | } |
@@ -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 | $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(); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function optionsFromTable($table, $key_field, $display_field, $SQLCondition = null) { |
43 | 43 | $data = DB::table($table); |
44 | - if($SQLCondition && is_callable($SQLCondition)) { |
|
44 | + if ($SQLCondition && is_callable($SQLCondition)) { |
|
45 | 45 | $data = call_user_func($SQLCondition, $data); |
46 | 46 | }elseif ($SQLCondition && is_string($SQLCondition)) { |
47 | 47 | $data->whereRaw($SQLCondition); |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | $data = $data->get(); |
50 | 50 | $options = []; |
51 | 51 | foreach ($data as $d) { |
52 | - $options[ $d->$key_field ] = $d->$display_field; |
|
52 | + $options[$d->$key_field] = $d->$display_field; |
|
53 | 53 | } |
54 | 54 | $data = columnSingleton()->getColumn($this->index); |
55 | 55 | /** @var $data SelectModel */ |
56 | - $data->setOptionsFromTable(["table"=>$table,"key_field"=>$key_field,"display_field"=>$display_field,"sql_condition"=>$SQLCondition]); |
|
56 | + $data->setOptionsFromTable(["table"=>$table, "key_field"=>$key_field, "display_field"=>$display_field, "sql_condition"=>$SQLCondition]); |
|
57 | 57 | columnSingleton()->setColumn($this->index, $data); |
58 | 58 | |
59 | 59 | $this->options($options); |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | columnSingleton()->setColumn($this->index, $data); |
70 | 70 | |
71 | 71 | $result = call_user_func($query); |
72 | - if($result) { |
|
72 | + if ($result) { |
|
73 | 73 | $options = []; |
74 | - foreach($result as $r) { |
|
75 | - $options[ $r->key ] = $r->label; |
|
74 | + foreach ($result as $r) { |
|
75 | + $options[$r->key] = $r->label; |
|
76 | 76 | } |
77 | 77 | $this->options($options); |
78 | 78 | } |