@@ -24,22 +24,22 @@ discard block |
||
24 | 24 | |
25 | 25 | public function getIndex() { |
26 | 26 | $data = []; |
27 | - return view($this->view.".index",$data); |
|
27 | + return view($this->view.".index", $data); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function getAdd() { |
31 | 31 | $data = []; |
32 | 32 | $data['form_title'] = "Add Menu"; |
33 | 33 | $data['form_url'] = route('DeveloperMenusControllerPostAddSave'); |
34 | - $data['modules'] = DB::table("cb_modules")->orderBy("name","asc")->get(); |
|
34 | + $data['modules'] = DB::table("cb_modules")->orderBy("name", "asc")->get(); |
|
35 | 35 | return view($this->view.".form", $data); |
36 | 36 | } |
37 | 37 | |
38 | 38 | public function getEdit($id) { |
39 | 39 | $data = []; |
40 | 40 | $data['form_title'] = "Edit Menu"; |
41 | - $data['form_url'] = route('DeveloperMenusControllerPostEditSave',['id'=>$id]); |
|
42 | - $data['modules'] = DB::table("cb_modules")->orderBy("name","asc")->get(); |
|
41 | + $data['form_url'] = route('DeveloperMenusControllerPostEditSave', ['id'=>$id]); |
|
42 | + $data['modules'] = DB::table("cb_modules")->orderBy("name", "asc")->get(); |
|
43 | 43 | $data['row'] = cb()->find("cb_menus", $id); |
44 | 44 | return view($this->view.".form", $data); |
45 | 45 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $menu['name'] = request('name'); |
53 | 53 | $menu['icon'] = request('icon'); |
54 | 54 | $menu['type'] = request('type'); |
55 | - if(request('type') == 'module') { |
|
55 | + if (request('type') == 'module') { |
|
56 | 56 | $menu['cb_modules_id'] = request('cb_modules_id'); |
57 | 57 | }elseif (request('type') == 'url') { |
58 | 58 | $menu['path'] = request('url_value'); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | DB::table("cb_menus")->insert($menu); |
64 | 64 | |
65 | - return cb()->redirect(route("DeveloperMenusControllerGetIndex"),"The menu has been added!","success"); |
|
65 | + return cb()->redirect(route("DeveloperMenusControllerGetIndex"), "The menu has been added!", "success"); |
|
66 | 66 | |
67 | 67 | } catch (CBValidationException $e) { |
68 | 68 | return cb()->redirectBack($e->getMessage()); |
@@ -77,16 +77,16 @@ discard block |
||
77 | 77 | $menu['name'] = request('name'); |
78 | 78 | $menu['icon'] = request('icon'); |
79 | 79 | $menu['type'] = request('type'); |
80 | - if(request('type') == 'module') { |
|
80 | + if (request('type') == 'module') { |
|
81 | 81 | $menu['cb_modules_id'] = request('cb_modules_id'); |
82 | 82 | }elseif (request('type') == 'url') { |
83 | 83 | $menu['path'] = request('url_value'); |
84 | 84 | }elseif (request('type') == 'path') { |
85 | 85 | $menu['path'] = request('path_value'); |
86 | 86 | } |
87 | - DB::table("cb_menus")->where("id",$id)->update($menu); |
|
87 | + DB::table("cb_menus")->where("id", $id)->update($menu); |
|
88 | 88 | |
89 | - return cb()->redirect(route("DeveloperMenusControllerGetIndex"),"The menu has been saved!","success"); |
|
89 | + return cb()->redirect(route("DeveloperMenusControllerGetIndex"), "The menu has been saved!", "success"); |
|
90 | 90 | |
91 | 91 | } catch (CBValidationException $e) { |
92 | 92 | return cb()->redirectBack($e->getMessage()); |
@@ -99,20 +99,20 @@ discard block |
||
99 | 99 | |
100 | 100 | $menus = request('menus'); |
101 | 101 | $menus = json_decode($menus, true); |
102 | - if($menus) { |
|
102 | + if ($menus) { |
|
103 | 103 | $menus = $menus[0]; |
104 | - if($menus) { |
|
105 | - foreach($menus as $i=>$menu) { |
|
104 | + if ($menus) { |
|
105 | + foreach ($menus as $i=>$menu) { |
|
106 | 106 | $id = $menu['id']; |
107 | - cb()->update("cb_menus",$id,["sort_number"=>$i,'parent_cb_menus_id'=>null]); |
|
108 | - if($menu['children'][0]) { |
|
109 | - foreach($menu['children'][0] as $ii=>$sub) { |
|
107 | + cb()->update("cb_menus", $id, ["sort_number"=>$i, 'parent_cb_menus_id'=>null]); |
|
108 | + if ($menu['children'][0]) { |
|
109 | + foreach ($menu['children'][0] as $ii=>$sub) { |
|
110 | 110 | $id = $sub['id']; |
111 | - cb()->update("cb_menus",$id,["sort_number"=>$ii,"parent_cb_menus_id"=>$menu['id']]); |
|
112 | - if($sub['children'][0]) { |
|
113 | - foreach($sub['children'][0] as $iii=>$subsub) { |
|
111 | + cb()->update("cb_menus", $id, ["sort_number"=>$ii, "parent_cb_menus_id"=>$menu['id']]); |
|
112 | + if ($sub['children'][0]) { |
|
113 | + foreach ($sub['children'][0] as $iii=>$subsub) { |
|
114 | 114 | $id = $subsub['id']; |
115 | - cb()->update("cb_menus",$id,["sort_number"=>$iii,"parent_cb_menus_id"=>$sub['id']]); |
|
115 | + cb()->update("cb_menus", $id, ["sort_number"=>$iii, "parent_cb_menus_id"=>$sub['id']]); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | } |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
124 | - return response()->json(['api_status'=>1,'api_message'=>'success']); |
|
124 | + return response()->json(['api_status'=>1, 'api_message'=>'success']); |
|
125 | 125 | |
126 | 126 | } catch (CBValidationException $e) { |
127 | - return response()->json(['api_status'=>0,'api_message'=>$e->getMessage()]); |
|
127 | + return response()->json(['api_status'=>0, 'api_message'=>$e->getMessage()]); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
131 | 131 | public function getDelete($id) { |
132 | - DB::table("cb_menus")->where("id",$id)->delete(); |
|
132 | + DB::table("cb_menus")->where("id", $id)->delete(); |
|
133 | 133 | DB::table("cb_role_privileges")->where("cb_menus_id", $id)->delete(); |
134 | 134 | |
135 | - return cb()->redirectBack("The menu has been deleted!","success"); |
|
135 | + return cb()->redirectBack("The menu has been deleted!", "success"); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | } |
139 | 139 | \ No newline at end of file |
@@ -27,14 +27,14 @@ discard block |
||
27 | 27 | |
28 | 28 | public function __call($method, $parameters) |
29 | 29 | { |
30 | - if($method == "getData") { |
|
30 | + if ($method == "getData") { |
|
31 | 31 | $key = $parameters[0]; |
32 | - if(isset($this->data[$key])) { |
|
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 | } |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | |
49 | 49 | $query->addSelect($this->data['table'].'.'.cb()->pk($this->data['table']).' as primary_key'); |
50 | 50 | |
51 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
52 | - if($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
51 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
52 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
53 | 53 | $query->whereNull($this->data['table'].'.deleted_at'); |
54 | 54 | } |
55 | 55 | |
56 | - if(isset($joins)) { |
|
57 | - foreach($joins as $join) |
|
56 | + if (isset($joins)) { |
|
57 | + foreach ($joins as $join) |
|
58 | 58 | { |
59 | 59 | $query->join($join['target_table'], |
60 | 60 | $join['target_table_primary'], |
@@ -64,14 +64,14 @@ discard block |
||
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | - foreach($columns as $column) { |
|
67 | + foreach ($columns as $column) { |
|
68 | 68 | /** @var ColumnModel $column */ |
69 | - if($column->getType() != "custom") { |
|
70 | - if(strpos($column->getField(),".") === false) { |
|
71 | - if(Schema::hasColumn($this->data['table'], $column->getField())) { |
|
69 | + if ($column->getType() != "custom") { |
|
70 | + if (strpos($column->getField(), ".") === false) { |
|
71 | + if (Schema::hasColumn($this->data['table'], $column->getField())) { |
|
72 | 72 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
73 | 73 | } |
74 | - }else{ |
|
74 | + } else { |
|
75 | 75 | $query->addSelect($column->getField()); |
76 | 76 | } |
77 | 77 | } |
@@ -79,20 +79,20 @@ discard block |
||
79 | 79 | $query = getTypeHook($column->getType())->query($query, $column); |
80 | 80 | } |
81 | 81 | |
82 | - if(request()->has('q')) |
|
82 | + if (request()->has('q')) |
|
83 | 83 | { |
84 | - if(isset($this->data['hook_search_query'])) { |
|
84 | + if (isset($this->data['hook_search_query'])) { |
|
85 | 85 | $query = call_user_func($this->data['hook_search_query'], $query); |
86 | - }else{ |
|
87 | - $query->where(function ($where) use ($columns) { |
|
86 | + } else { |
|
87 | + $query->where(function($where) use ($columns) { |
|
88 | 88 | /** |
89 | 89 | * @var $where Builder |
90 | 90 | */ |
91 | - foreach($columns as $column) |
|
91 | + foreach ($columns as $column) |
|
92 | 92 | { |
93 | - if(strpos($column->getField(),".") === false) { |
|
93 | + if (strpos($column->getField(), ".") === false) { |
|
94 | 94 | $field = $this->data['table'].'.'.$column->getField(); |
95 | - }else{ |
|
95 | + } else { |
|
96 | 96 | $field = $column->getField(); |
97 | 97 | } |
98 | 98 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -103,21 +103,21 @@ discard block |
||
103 | 103 | |
104 | 104 | |
105 | 105 | // Callback From this Method |
106 | - if(isset($callback) && is_callable($callback)) { |
|
106 | + if (isset($callback) && is_callable($callback)) { |
|
107 | 107 | $query = call_user_func($callback, $query); |
108 | 108 | } |
109 | 109 | |
110 | - if(isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) { |
|
110 | + if (isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) { |
|
111 | 111 | $query = call_user_func($this->data['hook_index_query'], $query); |
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | - if(request()->has(['order_by','order_sort'])) |
|
115 | + if (request()->has(['order_by', 'order_sort'])) |
|
116 | 116 | { |
117 | - if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
|
117 | + if (in_array(request('order_by'), columnSingleton()->getColumnNameOnly())) { |
|
118 | 118 | $query->orderBy(request('order_by'), request('order_sort')); |
119 | 119 | } |
120 | - }else{ |
|
120 | + } else { |
|
121 | 121 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
122 | 122 | } |
123 | 123 | |
@@ -126,29 +126,29 @@ discard block |
||
126 | 126 | |
127 | 127 | public function getIndex() |
128 | 128 | { |
129 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
129 | + if (!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
130 | 130 | |
131 | 131 | $query = $this->repository(); |
132 | - $result = $query->paginate( request("limit")?:cbConfig("LIMIT_TABLE_DATA") ); |
|
132 | + $result = $query->paginate(request("limit") ?: cbConfig("LIMIT_TABLE_DATA")); |
|
133 | 133 | $data['result'] = $result; |
134 | 134 | |
135 | 135 | return view("crudbooster::module.index.index", array_merge($data, $this->data)); |
136 | 136 | } |
137 | 137 | |
138 | 138 | public function getFilterBy($field, $value, $parentPath) { |
139 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
139 | + if (!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
140 | 140 | |
141 | - if(!verifyReferalUrl()) return cb()->redirect(cb()->getAdminUrl($parentPath),"The url you are trying visit is incorrect"); |
|
141 | + if (!verifyReferalUrl()) return cb()->redirect(cb()->getAdminUrl($parentPath), "The url you are trying visit is incorrect"); |
|
142 | 142 | |
143 | 143 | $query = $this->repository(); |
144 | 144 | |
145 | 145 | $query->where($field, $value); |
146 | 146 | |
147 | - $result = $query->paginate( request("limit")?:cbConfig("LIMIT_TABLE_DATA") ); |
|
147 | + $result = $query->paginate(request("limit") ?: cbConfig("LIMIT_TABLE_DATA")); |
|
148 | 148 | $data['result'] = $result; |
149 | 149 | |
150 | 150 | $additionalView = getReferalUrl("additional"); |
151 | - if($additionalView) { |
|
151 | + if ($additionalView) { |
|
152 | 152 | $data['additionalView'] = $additionalView; |
153 | 153 | } |
154 | 154 | |
@@ -161,29 +161,29 @@ discard block |
||
161 | 161 | */ |
162 | 162 | private function validation() |
163 | 163 | { |
164 | - if(isset($this->data['validation'])) { |
|
164 | + if (isset($this->data['validation'])) { |
|
165 | 165 | $validator = Validator::make(request()->all(), @$this->data['validation'], @$this->data['validation_messages']); |
166 | 166 | if ($validator->fails()) { |
167 | 167 | $message = $validator->messages(); |
168 | 168 | $message_all = $message->all(); |
169 | - throw new CBValidationException(implode(', ',$message_all)); |
|
169 | + throw new CBValidationException(implode(', ', $message_all)); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
174 | 174 | public function getAdd() |
175 | 175 | { |
176 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
176 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
177 | 177 | |
178 | 178 | $data = []; |
179 | 179 | $data['page_title'] = $this->data['page_title'].' : '.cbLang('add'); |
180 | 180 | $data['action_url'] = module()->addSaveURL(); |
181 | - return view('crudbooster::module.form.form',array_merge($data, $this->data)); |
|
181 | + return view('crudbooster::module.form.form', array_merge($data, $this->data)); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | public function postAddSave() |
185 | 185 | { |
186 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
186 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
187 | 187 | |
188 | 188 | try { |
189 | 189 | $this->validation(); |
@@ -191,38 +191,38 @@ discard block |
||
191 | 191 | $data = columnSingleton()->getAssignmentData(); |
192 | 192 | |
193 | 193 | //Clear data from Primary Key |
194 | - unset($data[ cb()->pk($this->data['table']) ]); |
|
194 | + unset($data[cb()->pk($this->data['table'])]); |
|
195 | 195 | |
196 | - if(Schema::hasColumn($this->data['table'], 'created_at')) { |
|
196 | + if (Schema::hasColumn($this->data['table'], 'created_at')) { |
|
197 | 197 | $data['created_at'] = date('Y-m-d H:i:s'); |
198 | 198 | } |
199 | 199 | |
200 | - if(Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
200 | + if (Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
201 | 201 | $data['updated_at'] = date('Y-m-d H:i:s'); |
202 | 202 | } |
203 | 203 | |
204 | - if(isset($this->data['hook_before_insert']) && is_callable($this->data['hook_before_insert'])) { |
|
204 | + if (isset($this->data['hook_before_insert']) && is_callable($this->data['hook_before_insert'])) { |
|
205 | 205 | $data = call_user_func($this->data['hook_before_insert'], $data); |
206 | 206 | } |
207 | 207 | |
208 | 208 | $id = DB::table($this->data['table'])->insertGetId($data); |
209 | 209 | |
210 | - if(isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
210 | + if (isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
211 | 211 | call_user_func($this->data['hook_after_insert'], $id); |
212 | 212 | } |
213 | 213 | |
214 | 214 | } catch (CBValidationException $e) { |
215 | 215 | Log::debug($e); |
216 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
216 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
217 | 217 | } catch (\Exception $e) { |
218 | 218 | Log::error($e); |
219 | - return cb()->redirectBack(cbLang("something_went_wrong"),'warning'); |
|
219 | + return cb()->redirectBack(cbLang("something_went_wrong"), 'warning'); |
|
220 | 220 | } |
221 | 221 | |
222 | - if (Str::contains(request("submit"),cbLang("more"))) { |
|
222 | + if (Str::contains(request("submit"), cbLang("more"))) { |
|
223 | 223 | return cb()->redirect(module()->addURL(), cbLang("the_data_has_been_added"), 'success'); |
224 | 224 | } else { |
225 | - if(verifyReferalUrl()) { |
|
225 | + if (verifyReferalUrl()) { |
|
226 | 226 | return cb()->redirect(getReferalUrl("url"), cbLang("the_data_has_been_added"), 'success'); |
227 | 227 | } else { |
228 | 228 | return cb()->redirect(module()->url(), cbLang("the_data_has_been_added"), 'success'); |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | |
233 | 233 | public function getEdit($id) |
234 | 234 | { |
235 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
235 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
236 | 236 | |
237 | 237 | $data = []; |
238 | 238 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | |
244 | 244 | public function postEditSave($id) |
245 | 245 | { |
246 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
246 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
247 | 247 | |
248 | 248 | try { |
249 | 249 | $this->validation(); |
@@ -251,40 +251,40 @@ discard block |
||
251 | 251 | $data = columnSingleton()->getAssignmentData(); |
252 | 252 | |
253 | 253 | // Make sure the Primary Key is not included |
254 | - unset($data[ cb()->pk($this->data['table']) ]); |
|
254 | + unset($data[cb()->pk($this->data['table'])]); |
|
255 | 255 | |
256 | - if(Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
256 | + if (Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
257 | 257 | $data['updated_at'] = date('Y-m-d H:i:s'); |
258 | 258 | } |
259 | 259 | |
260 | 260 | unset($data['created_at']); |
261 | 261 | |
262 | - if(isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
262 | + if (isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
263 | 263 | $data = call_user_func($this->data['hook_before_update'], $id, $data); |
264 | 264 | } |
265 | 265 | |
266 | 266 | cb()->update($this->data['table'], $id, $data); |
267 | 267 | |
268 | - if(isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
268 | + if (isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
269 | 269 | call_user_func($this->data['hook_after_update'], $id); |
270 | 270 | } |
271 | 271 | |
272 | 272 | } catch (CBValidationException $e) { |
273 | 273 | Log::debug($e); |
274 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
274 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
275 | 275 | } catch (\Exception $e) { |
276 | 276 | Log::error($e); |
277 | - return cb()->redirectBack(cbLang("something_went_wrong"),'warning'); |
|
277 | + return cb()->redirectBack(cbLang("something_went_wrong"), 'warning'); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | |
281 | 281 | if (Str::contains(request("submit"), cbLang("more"))) { |
282 | - return cb()->redirectBack( cbLang("the_data_has_been_updated"), 'success'); |
|
282 | + return cb()->redirectBack(cbLang("the_data_has_been_updated"), 'success'); |
|
283 | 283 | } else { |
284 | - if(verifyReferalUrl()) { |
|
285 | - return cb()->redirect(getReferalUrl("url"), cbLang("the_data_has_been_updated"), 'success'); |
|
284 | + if (verifyReferalUrl()) { |
|
285 | + return cb()->redirect(getReferalUrl("url"), cbLang("the_data_has_been_updated"), 'success'); |
|
286 | 286 | } else { |
287 | - return cb()->redirect(module()->url(), cbLang("the_data_has_been_updated"), 'success'); |
|
287 | + return cb()->redirect(module()->url(), cbLang("the_data_has_been_updated"), 'success'); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | } |
@@ -292,15 +292,15 @@ discard block |
||
292 | 292 | |
293 | 293 | public function getDelete($id) |
294 | 294 | { |
295 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
295 | + if (!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
296 | 296 | |
297 | - if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
297 | + if (isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
298 | 298 | call_user_func($this->data['hook_before_delete'], $id); |
299 | 299 | } |
300 | 300 | |
301 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
301 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
302 | 302 | |
303 | - if ($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
303 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
304 | 304 | DB::table($this->data['table']) |
305 | 305 | ->where(getPrimaryKey($this->data['table']), $id) |
306 | 306 | ->update(['deleted_at' => date('Y-m-d H:i:s')]); |
@@ -310,16 +310,16 @@ discard block |
||
310 | 310 | ->delete(); |
311 | 311 | } |
312 | 312 | |
313 | - if(isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
313 | + if (isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
314 | 314 | call_user_func($this->data['hook_after_delete'], $id); |
315 | 315 | } |
316 | 316 | |
317 | - return cb()->redirectBack( cbLang("the_data_has_been_deleted"), 'success'); |
|
317 | + return cb()->redirectBack(cbLang("the_data_has_been_deleted"), 'success'); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | public function getDetail($id) |
321 | 321 | { |
322 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
322 | + if (!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
323 | 323 | |
324 | 324 | $data = []; |
325 | 325 | $data['row'] = $this->repository()->where($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), $id)->first(); |
@@ -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 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if(Schema::hasColumn($this->data['table'], $column->getField())) { |
72 | 72 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
73 | 73 | } |
74 | - }else{ |
|
74 | + } else{ |
|
75 | 75 | $query->addSelect($column->getField()); |
76 | 76 | } |
77 | 77 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | { |
84 | 84 | if(isset($this->data['hook_search_query'])) { |
85 | 85 | $query = call_user_func($this->data['hook_search_query'], $query); |
86 | - }else{ |
|
86 | + } else{ |
|
87 | 87 | $query->where(function ($where) use ($columns) { |
88 | 88 | /** |
89 | 89 | * @var $where Builder |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | if(strpos($column->getField(),".") === false) { |
94 | 94 | $field = $this->data['table'].'.'.$column->getField(); |
95 | - }else{ |
|
95 | + } else{ |
|
96 | 96 | $field = $column->getField(); |
97 | 97 | } |
98 | 98 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
118 | 118 | $query->orderBy(request('order_by'), request('order_sort')); |
119 | 119 | } |
120 | - }else{ |
|
120 | + } else{ |
|
121 | 121 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
122 | 122 | } |
123 | 123 | |
@@ -126,7 +126,9 @@ discard block |
||
126 | 126 | |
127 | 127 | public function getIndex() |
128 | 128 | { |
129 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
129 | + if(!module()->canBrowse()) { |
|
130 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
131 | + } |
|
130 | 132 | |
131 | 133 | $query = $this->repository(); |
132 | 134 | $result = $query->paginate( request("limit")?:cbConfig("LIMIT_TABLE_DATA") ); |
@@ -136,9 +138,13 @@ discard block |
||
136 | 138 | } |
137 | 139 | |
138 | 140 | public function getFilterBy($field, $value, $parentPath) { |
139 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
141 | + if(!module()->canBrowse()) { |
|
142 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
143 | + } |
|
140 | 144 | |
141 | - if(!verifyReferalUrl()) return cb()->redirect(cb()->getAdminUrl($parentPath),"The url you are trying visit is incorrect"); |
|
145 | + if(!verifyReferalUrl()) { |
|
146 | + return cb()->redirect(cb()->getAdminUrl($parentPath),"The url you are trying visit is incorrect"); |
|
147 | + } |
|
142 | 148 | |
143 | 149 | $query = $this->repository(); |
144 | 150 | |
@@ -173,7 +179,9 @@ discard block |
||
173 | 179 | |
174 | 180 | public function getAdd() |
175 | 181 | { |
176 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
182 | + if(!module()->canCreate()) { |
|
183 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
184 | + } |
|
177 | 185 | |
178 | 186 | $data = []; |
179 | 187 | $data['page_title'] = $this->data['page_title'].' : '.cbLang('add'); |
@@ -183,7 +191,9 @@ discard block |
||
183 | 191 | |
184 | 192 | public function postAddSave() |
185 | 193 | { |
186 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
194 | + if(!module()->canCreate()) { |
|
195 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
196 | + } |
|
187 | 197 | |
188 | 198 | try { |
189 | 199 | $this->validation(); |
@@ -232,7 +242,9 @@ discard block |
||
232 | 242 | |
233 | 243 | public function getEdit($id) |
234 | 244 | { |
235 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
245 | + if(!module()->canUpdate()) { |
|
246 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
247 | + } |
|
236 | 248 | |
237 | 249 | $data = []; |
238 | 250 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -243,7 +255,9 @@ discard block |
||
243 | 255 | |
244 | 256 | public function postEditSave($id) |
245 | 257 | { |
246 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
258 | + if(!module()->canUpdate()) { |
|
259 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
260 | + } |
|
247 | 261 | |
248 | 262 | try { |
249 | 263 | $this->validation(); |
@@ -292,7 +306,9 @@ discard block |
||
292 | 306 | |
293 | 307 | public function getDelete($id) |
294 | 308 | { |
295 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
309 | + if(!module()->canDelete()) { |
|
310 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
311 | + } |
|
296 | 312 | |
297 | 313 | if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
298 | 314 | call_user_func($this->data['hook_before_delete'], $id); |
@@ -319,7 +335,9 @@ discard block |
||
319 | 335 | |
320 | 336 | public function getDetail($id) |
321 | 337 | { |
322 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
338 | + if(!module()->canRead()) { |
|
339 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
340 | + } |
|
323 | 341 | |
324 | 342 | $data = []; |
325 | 343 | $data['row'] = $this->repository()->where($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), $id)->first(); |
@@ -199,11 +199,11 @@ |
||
199 | 199 | $parentPath = $this->getData("permalink"); |
200 | 200 | $parentTitle = $this->getData("page_title"); |
201 | 201 | $this->addActionButton($label,function($row) use ($controllerName, $foreignKey, $additionalInfo, $parentPath, $parentTitle) { |
202 | - return action(class_basename($controllerName)."@getFilterBy",[ |
|
203 | - "field"=>$foreignKey, |
|
204 | - "value"=>$row->primary_key, |
|
205 | - "parentPath"=>$parentPath |
|
206 | - ])."?ref=".makeReferalUrl($parentTitle, (isset($additionalInfo)&&is_callable($additionalInfo))?call_user_func($additionalInfo,$row):[] ); |
|
202 | + return action(class_basename($controllerName)."@getFilterBy",[ |
|
203 | + "field"=>$foreignKey, |
|
204 | + "value"=>$row->primary_key, |
|
205 | + "parentPath"=>$parentPath |
|
206 | + ])."?ref=".makeReferalUrl($parentTitle, (isset($additionalInfo)&&is_callable($additionalInfo))?call_user_func($additionalInfo,$row):[] ); |
|
207 | 207 | }, $condition, $font, $color); |
208 | 208 | } |
209 | 209 |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | $this->setButtonDetail(true); |
30 | 30 | $this->setButtonSave(true); |
31 | 31 | $this->setButtonLimitPage(true); |
32 | - $this->hideButtonDeleteWhen(function ($row) { return false; }); |
|
33 | - $this->hideButtonDetailWhen(function ($row) { return false; }); |
|
34 | - $this->hideButtonEditWhen(function ($row) { return false; }); |
|
35 | - $this->style(function () { return null; }); |
|
36 | - $this->javascript(function () { return null; }); |
|
32 | + $this->hideButtonDeleteWhen(function($row) { return false; }); |
|
33 | + $this->hideButtonDetailWhen(function($row) { return false; }); |
|
34 | + $this->hideButtonEditWhen(function($row) { return false; }); |
|
35 | + $this->style(function() { return null; }); |
|
36 | + $this->javascript(function() { return null; }); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | public function style(callable $style) { |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | * @param ButtonColor $color |
138 | 138 | * @param string $attributes |
139 | 139 | */ |
140 | - public function addIndexActionButton($label, $actionURL, $fontAwesome_icon=null, $color=null, $attributes = null) |
|
140 | + public function addIndexActionButton($label, $actionURL, $fontAwesome_icon = null, $color = null, $attributes = null) |
|
141 | 141 | { |
142 | - $color = ($color)?:ButtonColor::DARK_BLUE; |
|
142 | + $color = ($color) ?: ButtonColor::DARK_BLUE; |
|
143 | 143 | |
144 | 144 | $model = new IndexActionButtonModel(); |
145 | 145 | $model->setLabel($label); |
@@ -198,12 +198,12 @@ discard block |
||
198 | 198 | public function addSubModule($label, $controllerName, $foreignKey, callable $additionalInfo = null, callable $condition = null, $font = null, $color = null) { |
199 | 199 | $parentPath = $this->getData("permalink"); |
200 | 200 | $parentTitle = $this->getData("page_title"); |
201 | - $this->addActionButton($label,function($row) use ($controllerName, $foreignKey, $additionalInfo, $parentPath, $parentTitle) { |
|
202 | - return action(class_basename($controllerName)."@getFilterBy",[ |
|
201 | + $this->addActionButton($label, function($row) use ($controllerName, $foreignKey, $additionalInfo, $parentPath, $parentTitle) { |
|
202 | + return action(class_basename($controllerName)."@getFilterBy", [ |
|
203 | 203 | "field"=>$foreignKey, |
204 | 204 | "value"=>$row->primary_key, |
205 | 205 | "parentPath"=>$parentPath |
206 | - ])."?ref=".makeReferalUrl($parentTitle, (isset($additionalInfo)&&is_callable($additionalInfo))?call_user_func($additionalInfo,$row):[] ); |
|
206 | + ])."?ref=".makeReferalUrl($parentTitle, (isset($additionalInfo) && is_callable($additionalInfo)) ?call_user_func($additionalInfo, $row) : []); |
|
207 | 207 | }, $condition, $font, $color); |
208 | 208 | } |
209 | 209 | |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | * @param $fontAwesome_icon |
216 | 216 | * @param ButtonColor|string $color |
217 | 217 | */ |
218 | - public function addActionButton($label, $url_target, $condition_callback=null, $fontAwesome_icon=null, $color=null, $confirmation = false) |
|
218 | + public function addActionButton($label, $url_target, $condition_callback = null, $fontAwesome_icon = null, $color = null, $confirmation = false) |
|
219 | 219 | { |
220 | 220 | $new = new AddActionButtonModel(); |
221 | 221 | $new->setLabel($label); |
222 | - $new->setIcon($fontAwesome_icon?:"fa fa-bars"); |
|
223 | - $new->setColor($color?:"primary"); |
|
222 | + $new->setIcon($fontAwesome_icon ?: "fa fa-bars"); |
|
223 | + $new->setColor($color ?: "primary"); |
|
224 | 224 | $new->setUrl($url_target); |
225 | 225 | $new->setCondition($condition_callback); |
226 | 226 | $new->setConfirmation($confirmation); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!function_exists("makeReferalUrl")) { |
|
3 | +if (!function_exists("makeReferalUrl")) { |
|
4 | 4 | function makeReferalUrl($name = null, $additionalVariables = []) { |
5 | 5 | $ref = []; |
6 | 6 | $ref['url'] = request()->fullUrl(); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | $ref['additional'] = $additionalVariables; |
9 | 9 | $md5Hash = md5(serialize($ref)); |
10 | 10 | |
11 | - if($exist = \Illuminate\Support\Facades\Cache::get("refurl_".$md5Hash)) { |
|
11 | + if ($exist = \Illuminate\Support\Facades\Cache::get("refurl_".$md5Hash)) { |
|
12 | 12 | return $exist['id']; |
13 | 13 | } |
14 | 14 | |
@@ -20,12 +20,12 @@ discard block |
||
20 | 20 | } |
21 | 21 | } |
22 | 22 | |
23 | -if(!function_exists("getReferalUrl")) { |
|
23 | +if (!function_exists("getReferalUrl")) { |
|
24 | 24 | function getReferalUrl($key = null) { |
25 | - if(verifyReferalUrl()) { |
|
25 | + if (verifyReferalUrl()) { |
|
26 | 26 | $md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref")); |
27 | 27 | $ref = \Illuminate\Support\Facades\Cache::get("refurl_".$md5hash); |
28 | - if($key) { |
|
28 | + if ($key) { |
|
29 | 29 | return $ref[$key]; |
30 | 30 | } else { |
31 | 31 | return $ref; |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | -if(!function_exists("verifyReferalUrl")) { |
|
38 | +if (!function_exists("verifyReferalUrl")) { |
|
39 | 39 | function verifyReferalUrl() |
40 | 40 | { |
41 | - if(request("ref")) { |
|
42 | - if($md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref"))) { |
|
41 | + if (request("ref")) { |
|
42 | + if ($md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref"))) { |
|
43 | 43 | $ref = \Illuminate\Support\Facades\Cache::get("refurl_".$md5hash); |
44 | - if(filter_var($ref['url'], FILTER_VALIDATE_URL)) { |
|
44 | + if (filter_var($ref['url'], FILTER_VALIDATE_URL)) { |
|
45 | 45 | return true; |
46 | 46 | } |
47 | 47 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | -if(!function_exists("findModuleByPermalink")) { |
|
53 | +if (!function_exists("findModuleByPermalink")) { |
|
54 | 54 | /** |
55 | 55 | * @param string $permalink |
56 | 56 | * @return \crocodicstudio\crudbooster\controllers\CBController|null |
@@ -58,25 +58,25 @@ discard block |
||
58 | 58 | function findControllerByPermalink($permalink) { |
59 | 59 | try { |
60 | 60 | $controllers = glob(app_path('Http/Controllers/Admin*Controller.php')); |
61 | - foreach($controllers as $controller) { |
|
61 | + foreach ($controllers as $controller) { |
|
62 | 62 | $controllerName = basename($controller); |
63 | - $controllerName = rtrim($controllerName,".php"); |
|
63 | + $controllerName = rtrim($controllerName, ".php"); |
|
64 | 64 | $className = '\App\Http\Controllers\\'.$controllerName; |
65 | 65 | $controllerClass = new $className(); |
66 | - if(method_exists($controllerClass, 'cbInit')) { |
|
67 | - if($permalink == $controllerClass->getData('permalink')) { |
|
66 | + if (method_exists($controllerClass, 'cbInit')) { |
|
67 | + if ($permalink == $controllerClass->getData('permalink')) { |
|
68 | 68 | return $controllerClass; |
69 | 69 | } |
70 | 70 | } |
71 | 71 | } |
72 | - }catch (\Exception $e) { |
|
72 | + } catch (\Exception $e) { |
|
73 | 73 | |
74 | 74 | } |
75 | 75 | return null; |
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | -if(!function_exists("putHtaccess")) { |
|
79 | +if (!function_exists("putHtaccess")) { |
|
80 | 80 | function putHtaccess($stringToPut) |
81 | 81 | { |
82 | 82 | file_put_contents(base_path(".htaccess"), "\n".$stringToPut, FILE_APPEND); |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | -if(!function_exists("checkHtaccess")) { |
|
87 | +if (!function_exists("checkHtaccess")) { |
|
88 | 88 | function checkHtaccess($stringToCheck) |
89 | 89 | { |
90 | - if(file_exists(base_path(".htaccess")) && file_exists(public_path(".htaccess"))) { |
|
90 | + if (file_exists(base_path(".htaccess")) && file_exists(public_path(".htaccess"))) { |
|
91 | 91 | $htaccess = file_get_contents(base_path(".htaccess")); |
92 | - $htaccess2= file_get_contents(public_path(".htaccess")); |
|
93 | - if(\Illuminate\Support\Str::contains($htaccess, $stringToCheck) && \Illuminate\Support\Str::contains($htaccess2, $stringToCheck)) { |
|
92 | + $htaccess2 = file_get_contents(public_path(".htaccess")); |
|
93 | + if (\Illuminate\Support\Str::contains($htaccess, $stringToCheck) && \Illuminate\Support\Str::contains($htaccess2, $stringToCheck)) { |
|
94 | 94 | return true; |
95 | 95 | } |
96 | 96 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | -if(!function_exists("setEnvironmentValue")) { |
|
102 | +if (!function_exists("setEnvironmentValue")) { |
|
103 | 103 | function setEnvironmentValue(array $values) |
104 | 104 | { |
105 | 105 | $envFile = app()->environmentFilePath(); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | |
133 | -if(!function_exists("cbLang")) { |
|
133 | +if (!function_exists("cbLang")) { |
|
134 | 134 | /** |
135 | 135 | * @param string $key |
136 | 136 | * @param array $replace |
@@ -142,17 +142,17 @@ discard block |
||
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | -if(!function_exists('rglob')) { |
|
145 | +if (!function_exists('rglob')) { |
|
146 | 146 | function rglob($pattern, $flags = 0) { |
147 | 147 | $files = glob($pattern, $flags); |
148 | - foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) { |
|
148 | + foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { |
|
149 | 149 | $files = array_merge($files, rglob($dir.'/'.basename($pattern), $flags)); |
150 | 150 | } |
151 | 151 | return $files; |
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
155 | -if(!function_exists('convertPHPToMomentFormat')) { |
|
155 | +if (!function_exists('convertPHPToMomentFormat')) { |
|
156 | 156 | function convertPHPToMomentFormat($format) |
157 | 157 | { |
158 | 158 | $replacements = [ |
@@ -199,13 +199,13 @@ discard block |
||
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | -if(!function_exists('slug')) { |
|
202 | +if (!function_exists('slug')) { |
|
203 | 203 | function slug($string, $separator = '-') { |
204 | 204 | return \Illuminate\Support\Str::slug($string, $separator); |
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | -if(!function_exists('columnSingleton')) { |
|
208 | +if (!function_exists('columnSingleton')) { |
|
209 | 209 | /** |
210 | 210 | * @return \crocodicstudio\crudbooster\controllers\scaffolding\singletons\ColumnSingleton |
211 | 211 | */ |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | -if(!function_exists('cbHook')) |
|
217 | +if (!function_exists('cbHook')) |
|
218 | 218 | { |
219 | 219 | /** |
220 | 220 | * @return crocodicstudio\crudbooster\hooks\CBHook |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
229 | -if(!function_exists('getTypeHook')) |
|
229 | +if (!function_exists('getTypeHook')) |
|
230 | 230 | { |
231 | 231 | /** |
232 | 232 | * @param string $type |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | } |
240 | 240 | } |
241 | 241 | |
242 | -if(!function_exists('getPrimaryKey')) |
|
242 | +if (!function_exists('getPrimaryKey')) |
|
243 | 243 | { |
244 | 244 | function getPrimaryKey($table_name) |
245 | 245 | { |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
250 | -if(!function_exists('cb')) |
|
250 | +if (!function_exists('cb')) |
|
251 | 251 | { |
252 | 252 | function cb() |
253 | 253 | { |
@@ -255,25 +255,25 @@ discard block |
||
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
258 | -if(!function_exists('cbAsset')) { |
|
258 | +if (!function_exists('cbAsset')) { |
|
259 | 259 | function cbAsset($path, $secure = null) { |
260 | 260 | return asset("cb_asset/".$path, $secure); |
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | -if(!function_exists("cbConfig")) { |
|
264 | +if (!function_exists("cbConfig")) { |
|
265 | 265 | function cbConfig($name, $default = null) { |
266 | 266 | return config("crudbooster.".$name, $default); |
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
270 | -if(!function_exists("strRandom")) { |
|
270 | +if (!function_exists("strRandom")) { |
|
271 | 271 | function strRandom($length = 5) { |
272 | 272 | return \Illuminate\Support\Str::random($length); |
273 | 273 | } |
274 | 274 | } |
275 | 275 | |
276 | -if(!function_exists('module')) { |
|
276 | +if (!function_exists('module')) { |
|
277 | 277 | function module() |
278 | 278 | { |
279 | 279 | $module = new \crocodicstudio\crudbooster\helpers\Module(); |
@@ -281,21 +281,21 @@ discard block |
||
281 | 281 | } |
282 | 282 | } |
283 | 283 | |
284 | -if(!function_exists('getAdminLoginURL')) { |
|
284 | +if (!function_exists('getAdminLoginURL')) { |
|
285 | 285 | function getAdminLoginURL() |
286 | 286 | { |
287 | 287 | return cb()->getAdminUrl("login"); |
288 | 288 | } |
289 | 289 | } |
290 | 290 | |
291 | -if(!function_exists('dummyPhoto')) { |
|
291 | +if (!function_exists('dummyPhoto')) { |
|
292 | 292 | function dummyPhoto() |
293 | 293 | { |
294 | 294 | return cbConfig("DUMMY_PHOTO"); |
295 | 295 | } |
296 | 296 | } |
297 | 297 | |
298 | -if(!function_exists('extract_unit')) { |
|
298 | +if (!function_exists('extract_unit')) { |
|
299 | 299 | /* |
300 | 300 | Credits: Bit Repository |
301 | 301 | URL: http://www.bitrepository.com/extract-content-between-two-delimiters-with-php.html |
@@ -320,14 +320,14 @@ discard block |
||
320 | 320 | | |
321 | 321 | */ |
322 | 322 | |
323 | -if(!function_exists('putSetting')) { |
|
323 | +if (!function_exists('putSetting')) { |
|
324 | 324 | function putSetting($key, $value) |
325 | 325 | { |
326 | - if(file_exists(storage_path('.cbconfig'))) { |
|
326 | + if (file_exists(storage_path('.cbconfig'))) { |
|
327 | 327 | $settings = file_get_contents(storage_path('.cbconfig')); |
328 | 328 | $settings = decrypt($settings); |
329 | 329 | $settings = unserialize($settings); |
330 | - }else{ |
|
330 | + } else { |
|
331 | 331 | $settings = []; |
332 | 332 | } |
333 | 333 | |
@@ -341,31 +341,31 @@ discard block |
||
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
344 | -if(!function_exists('getSetting')) { |
|
344 | +if (!function_exists('getSetting')) { |
|
345 | 345 | function getSetting($key, $default = null) |
346 | 346 | { |
347 | - if($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) { |
|
347 | + if ($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) { |
|
348 | 348 | return $cache; |
349 | 349 | } |
350 | 350 | |
351 | - if(file_exists(storage_path('.cbconfig'))) { |
|
351 | + if (file_exists(storage_path('.cbconfig'))) { |
|
352 | 352 | $settings = file_get_contents(storage_path('.cbconfig')); |
353 | 353 | $settings = decrypt($settings); |
354 | 354 | $settings = unserialize($settings); |
355 | - }else{ |
|
355 | + } else { |
|
356 | 356 | $settings = []; |
357 | 357 | } |
358 | 358 | |
359 | - if(isset($settings[$key])) { |
|
359 | + if (isset($settings[$key])) { |
|
360 | 360 | \Illuminate\Support\Facades\Cache::forever("setting_".$key, $settings[$key]); |
361 | - return $settings[$key]?:$default; |
|
362 | - }else{ |
|
361 | + return $settings[$key] ?: $default; |
|
362 | + } else { |
|
363 | 363 | return $default; |
364 | 364 | } |
365 | 365 | } |
366 | 366 | } |
367 | 367 | |
368 | -if(!function_exists('timeAgo')) { |
|
368 | +if (!function_exists('timeAgo')) { |
|
369 | 369 | function timeAgo($datetime_to, $datetime_from = null, $full = false) |
370 | 370 | { |
371 | 371 | $datetime_from = ($datetime_from) ?: date('Y-m-d H:i:s'); |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | } |
397 | 397 | } |
398 | 398 | |
399 | - if (! $full) { |
|
399 | + if (!$full) { |
|
400 | 400 | $string = array_slice($string, 0, 1); |
401 | 401 | } |
402 | 402 | |
@@ -404,22 +404,22 @@ discard block |
||
404 | 404 | } |
405 | 405 | } |
406 | 406 | |
407 | -if(!function_exists("array_map_r")) { |
|
408 | - function array_map_r( $func, $arr ) |
|
407 | +if (!function_exists("array_map_r")) { |
|
408 | + function array_map_r($func, $arr) |
|
409 | 409 | { |
410 | 410 | $newArr = array(); |
411 | 411 | |
412 | - foreach( $arr as $key => $value ) |
|
412 | + foreach ($arr as $key => $value) |
|
413 | 413 | { |
414 | 414 | $key = $func($key); |
415 | - $newArr[ $key ] = ( is_array( $value ) ? array_map_r( $func, $value ) : ( is_array($func) ? call_user_func_array($func, $value) : $func( $value ) ) ); |
|
415 | + $newArr[$key] = (is_array($value) ? array_map_r($func, $value) : (is_array($func) ? call_user_func_array($func, $value) : $func($value))); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | return $newArr; |
419 | 419 | } |
420 | 420 | } |
421 | 421 | |
422 | -if(!function_exists("sanitizeXSS")) |
|
422 | +if (!function_exists("sanitizeXSS")) |
|
423 | 423 | { |
424 | 424 | function sanitizeXSS($value) |
425 | 425 | { |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | } |
432 | 432 | } |
433 | 433 | |
434 | -if(!function_exists("requestAll")) { |
|
434 | +if (!function_exists("requestAll")) { |
|
435 | 435 | function requestAll() { |
436 | 436 | $all = array_map_r("sanitizeXSS", request()->all()); |
437 | 437 | return $all; |
@@ -440,22 +440,22 @@ discard block |
||
440 | 440 | |
441 | 441 | |
442 | 442 | |
443 | -if(!function_exists('getURLFormat')) { |
|
443 | +if (!function_exists('getURLFormat')) { |
|
444 | 444 | function getURLFormat($name) { |
445 | 445 | $url = request($name); |
446 | - if(filter_var($url, FILTER_VALIDATE_URL)) { |
|
446 | + if (filter_var($url, FILTER_VALIDATE_URL)) { |
|
447 | 447 | return $url; |
448 | - }else{ |
|
448 | + } else { |
|
449 | 449 | return request()->url(); |
450 | 450 | } |
451 | 451 | } |
452 | 452 | } |
453 | 453 | |
454 | -if(!function_exists('g')) { |
|
454 | +if (!function_exists('g')) { |
|
455 | 455 | function g($name, $safe = true) { |
456 | - if($safe == true) { |
|
456 | + if ($safe == true) { |
|
457 | 457 | $response = request($name); |
458 | - if(is_string($response)) { |
|
458 | + if (is_string($response)) { |
|
459 | 459 | $response = sanitizeXSS($response); |
460 | 460 | }elseif (is_array($response)) { |
461 | 461 | array_walk_recursive($response, function(&$response) { |
@@ -464,25 +464,25 @@ discard block |
||
464 | 464 | } |
465 | 465 | |
466 | 466 | return $response; |
467 | - }else{ |
|
467 | + } else { |
|
468 | 468 | return Request::get($name); |
469 | 469 | } |
470 | 470 | } |
471 | 471 | } |
472 | 472 | |
473 | -if(!function_exists('min_var_export')) { |
|
473 | +if (!function_exists('min_var_export')) { |
|
474 | 474 | function min_var_export($input) { |
475 | - if(is_array($input)) { |
|
475 | + if (is_array($input)) { |
|
476 | 476 | $buffer = []; |
477 | - foreach($input as $key => $value) |
|
477 | + foreach ($input as $key => $value) |
|
478 | 478 | $buffer[] = var_export($key, true)."=>".min_var_export($value); |
479 | - return "[".implode(",",$buffer)."]"; |
|
479 | + return "[".implode(",", $buffer)."]"; |
|
480 | 480 | } else |
481 | 481 | return var_export($input, true); |
482 | 482 | } |
483 | 483 | } |
484 | 484 | |
485 | -if(!function_exists('rrmdir')) { |
|
485 | +if (!function_exists('rrmdir')) { |
|
486 | 486 | /* |
487 | 487 | * http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir |
488 | 488 | */ |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | } |
70 | 70 | } |
71 | 71 | } |
72 | - }catch (\Exception $e) { |
|
72 | + } catch (\Exception $e) { |
|
73 | 73 | |
74 | 74 | } |
75 | 75 | return null; |
@@ -124,7 +124,9 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | $str = substr($str, 0, -1); |
127 | - if (!file_put_contents($envFile, $str)) return false; |
|
127 | + if (!file_put_contents($envFile, $str)) { |
|
128 | + return false; |
|
129 | + } |
|
128 | 130 | return true; |
129 | 131 | } |
130 | 132 | } |
@@ -327,7 +329,7 @@ discard block |
||
327 | 329 | $settings = file_get_contents(storage_path('.cbconfig')); |
328 | 330 | $settings = decrypt($settings); |
329 | 331 | $settings = unserialize($settings); |
330 | - }else{ |
|
332 | + } else{ |
|
331 | 333 | $settings = []; |
332 | 334 | } |
333 | 335 | |
@@ -352,14 +354,14 @@ discard block |
||
352 | 354 | $settings = file_get_contents(storage_path('.cbconfig')); |
353 | 355 | $settings = decrypt($settings); |
354 | 356 | $settings = unserialize($settings); |
355 | - }else{ |
|
357 | + } else{ |
|
356 | 358 | $settings = []; |
357 | 359 | } |
358 | 360 | |
359 | 361 | if(isset($settings[$key])) { |
360 | 362 | \Illuminate\Support\Facades\Cache::forever("setting_".$key, $settings[$key]); |
361 | 363 | return $settings[$key]?:$default; |
362 | - }else{ |
|
364 | + } else{ |
|
363 | 365 | return $default; |
364 | 366 | } |
365 | 367 | } |
@@ -445,7 +447,7 @@ discard block |
||
445 | 447 | $url = request($name); |
446 | 448 | if(filter_var($url, FILTER_VALIDATE_URL)) { |
447 | 449 | return $url; |
448 | - }else{ |
|
450 | + } else{ |
|
449 | 451 | return request()->url(); |
450 | 452 | } |
451 | 453 | } |
@@ -457,14 +459,14 @@ discard block |
||
457 | 459 | $response = request($name); |
458 | 460 | if(is_string($response)) { |
459 | 461 | $response = sanitizeXSS($response); |
460 | - }elseif (is_array($response)) { |
|
462 | + } elseif (is_array($response)) { |
|
461 | 463 | array_walk_recursive($response, function(&$response) { |
462 | 464 | $response = sanitizeXSS($response); |
463 | 465 | }); |
464 | 466 | } |
465 | 467 | |
466 | 468 | return $response; |
467 | - }else{ |
|
469 | + } else{ |
|
468 | 470 | return Request::get($name); |
469 | 471 | } |
470 | 472 | } |
@@ -474,11 +476,13 @@ discard block |
||
474 | 476 | function min_var_export($input) { |
475 | 477 | if(is_array($input)) { |
476 | 478 | $buffer = []; |
477 | - foreach($input as $key => $value) |
|
478 | - $buffer[] = var_export($key, true)."=>".min_var_export($value); |
|
479 | + foreach($input as $key => $value) { |
|
480 | + $buffer[] = var_export($key, true)."=>".min_var_export($value); |
|
481 | + } |
|
479 | 482 | return "[".implode(",",$buffer)."]"; |
480 | - } else |
|
481 | - return var_export($input, true); |
|
483 | + } else { |
|
484 | + return var_export($input, true); |
|
485 | + } |
|
482 | 486 | } |
483 | 487 | } |
484 | 488 | |
@@ -491,10 +495,11 @@ discard block |
||
491 | 495 | $objects = scandir($dir); |
492 | 496 | foreach ($objects as $object) { |
493 | 497 | if ($object != "." && $object != "..") { |
494 | - if (is_dir($dir."/".$object)) |
|
495 | - rrmdir($dir."/".$object); |
|
496 | - else |
|
497 | - unlink($dir."/".$object); |
|
498 | + if (is_dir($dir."/".$object)) { |
|
499 | + rrmdir($dir."/".$object); |
|
500 | + } else { |
|
501 | + unlink($dir."/".$object); |
|
502 | + } |
|
498 | 503 | } |
499 | 504 | } |
500 | 505 | rmdir($dir); |