@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | private function assignToModel($menu) { |
23 | 23 | $model = new SidebarModel(); |
24 | 24 | $model->setId($menu->id); |
25 | - if($menu->type == "url") { |
|
25 | + if ($menu->type == "url") { |
|
26 | 26 | $model->setUrl($menu->path); |
27 | 27 | $model->setIcon($menu->icon); |
28 | 28 | $model->setName($menu->name); |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | $model->setBasepath(config('crudbooster.ADMIN_PATH').'/'.basename($model->getUrl())); |
44 | 44 | } |
45 | 45 | |
46 | - if(request()->is($model->getBasepath()."*")) { |
|
46 | + if (request()->is($model->getBasepath()."*")) { |
|
47 | 47 | $model->setIsActive(true); |
48 | - }else{ |
|
48 | + } else { |
|
49 | 49 | $model->setIsActive(false); |
50 | 50 | } |
51 | 51 | |
@@ -54,22 +54,22 @@ discard block |
||
54 | 54 | |
55 | 55 | private function loadData($parent_id = null) { |
56 | 56 | $menus = DB::table("cb_menus"); |
57 | - if($parent_id) { |
|
58 | - $menus->where("parent_cb_menus_id",$parent_id); |
|
59 | - }else{ |
|
57 | + if ($parent_id) { |
|
58 | + $menus->where("parent_cb_menus_id", $parent_id); |
|
59 | + } else { |
|
60 | 60 | $menus->whereNull("parent_cb_menus_id"); |
61 | 61 | } |
62 | - return $menus->orderBy("sort_number","asc")->get(); |
|
62 | + return $menus->orderBy("sort_number", "asc")->get(); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | private function rolePrivilege($cb_roles_id, $cb_menus_id) { |
66 | - return cb()->find("cb_role_privileges",['cb_roles_id'=>$cb_roles_id,'cb_menus_id'=>$cb_menus_id]); |
|
66 | + return cb()->find("cb_role_privileges", ['cb_roles_id'=>$cb_roles_id, 'cb_menus_id'=>$cb_menus_id]); |
|
67 | 67 | } |
68 | 68 | |
69 | - private function checkPrivilege($roles_id,$menu) { |
|
70 | - if($roles_id) { |
|
69 | + private function checkPrivilege($roles_id, $menu) { |
|
70 | + if ($roles_id) { |
|
71 | 71 | $privilege = $this->rolePrivilege($roles_id, $menu->id); |
72 | - if($privilege && !$privilege->can_browse) { |
|
72 | + if ($privilege && !$privilege->can_browse) { |
|
73 | 73 | return false; |
74 | 74 | } |
75 | 75 | } |
@@ -78,36 +78,36 @@ discard block |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | public function all($withPrivilege = true) { |
81 | - $roles_id = ($withPrivilege)?cb()->session()->roleId():null; |
|
81 | + $roles_id = ($withPrivilege) ?cb()->session()->roleId() : null; |
|
82 | 82 | $menus = $this->loadData(); |
83 | 83 | $result = []; |
84 | 84 | $menus_active = false; |
85 | - foreach($menus as $menu) { |
|
85 | + foreach ($menus as $menu) { |
|
86 | 86 | |
87 | - if($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) continue; |
|
87 | + if ($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) continue; |
|
88 | 88 | |
89 | 89 | $sidebarModel = $this->assignToModel($menu); |
90 | - if($sidebarModel->getisActive()) $menus_active = true; |
|
91 | - if($menus2 = $this->loadData($menu->id)) { |
|
90 | + if ($sidebarModel->getisActive()) $menus_active = true; |
|
91 | + if ($menus2 = $this->loadData($menu->id)) { |
|
92 | 92 | $sub1 = []; |
93 | 93 | $menus2_active = false; |
94 | 94 | foreach ($menus2 as $menu2) { |
95 | 95 | |
96 | - if($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) continue; |
|
96 | + if ($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) continue; |
|
97 | 97 | |
98 | 98 | $sidebarModel2 = $this->assignToModel($menu2); |
99 | - if($sidebarModel2->getisActive()) $menus2_active = true; |
|
99 | + if ($sidebarModel2->getisActive()) $menus2_active = true; |
|
100 | 100 | |
101 | - if($menus3 = $this->loadData($menu2->id)) { |
|
101 | + if ($menus3 = $this->loadData($menu2->id)) { |
|
102 | 102 | $sub2 = []; |
103 | 103 | $menus3_active = false; |
104 | 104 | foreach ($menus3 as $menu3) { |
105 | 105 | |
106 | - if($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) continue; |
|
106 | + if ($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) continue; |
|
107 | 107 | |
108 | 108 | $sidebarModel3 = $this->assignToModel($menu3); |
109 | 109 | |
110 | - if($sidebarModel3->getisActive()) { |
|
110 | + if ($sidebarModel3->getisActive()) { |
|
111 | 111 | $menus3_active = true; |
112 | 112 | } |
113 | 113 |
@@ -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); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | if(request()->is($model->getBasepath()."*")) { |
47 | 47 | $model->setIsActive(true); |
48 | - }else{ |
|
48 | + } else{ |
|
49 | 49 | $model->setIsActive(false); |
50 | 50 | } |
51 | 51 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $menus = DB::table("cb_menus"); |
57 | 57 | if($parent_id) { |
58 | 58 | $menus->where("parent_cb_menus_id",$parent_id); |
59 | - }else{ |
|
59 | + } else{ |
|
60 | 60 | $menus->whereNull("parent_cb_menus_id"); |
61 | 61 | } |
62 | 62 | return $menus->orderBy("sort_number","asc")->get(); |
@@ -84,26 +84,36 @@ discard block |
||
84 | 84 | $menus_active = false; |
85 | 85 | foreach($menus as $menu) { |
86 | 86 | |
87 | - if($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) continue; |
|
87 | + if($withPrivilege && !$this->checkPrivilege($roles_id, $menu)) { |
|
88 | + continue; |
|
89 | + } |
|
88 | 90 | |
89 | 91 | $sidebarModel = $this->assignToModel($menu); |
90 | - if($sidebarModel->getisActive()) $menus_active = true; |
|
92 | + if($sidebarModel->getisActive()) { |
|
93 | + $menus_active = true; |
|
94 | + } |
|
91 | 95 | if($menus2 = $this->loadData($menu->id)) { |
92 | 96 | $sub1 = []; |
93 | 97 | $menus2_active = false; |
94 | 98 | foreach ($menus2 as $menu2) { |
95 | 99 | |
96 | - if($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) continue; |
|
100 | + if($withPrivilege && !$this->checkPrivilege($roles_id, $menu2)) { |
|
101 | + continue; |
|
102 | + } |
|
97 | 103 | |
98 | 104 | $sidebarModel2 = $this->assignToModel($menu2); |
99 | - if($sidebarModel2->getisActive()) $menus2_active = true; |
|
105 | + if($sidebarModel2->getisActive()) { |
|
106 | + $menus2_active = true; |
|
107 | + } |
|
100 | 108 | |
101 | 109 | if($menus3 = $this->loadData($menu2->id)) { |
102 | 110 | $sub2 = []; |
103 | 111 | $menus3_active = false; |
104 | 112 | foreach ($menus3 as $menu3) { |
105 | 113 | |
106 | - if($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) continue; |
|
114 | + if($withPrivilege && !$this->checkPrivilege($roles_id, $menu3)) { |
|
115 | + continue; |
|
116 | + } |
|
107 | 117 | |
108 | 118 | $sidebarModel3 = $this->assignToModel($menu3); |
109 | 119 |
@@ -29,9 +29,9 @@ 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; }); |
|
32 | + $this->hideButtonDeleteWhen(function($row) { return false; }); |
|
33 | + $this->hideButtonDetailWhen(function($row) { return false; }); |
|
34 | + $this->hideButtonEditWhen(function($row) { return false; }); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | * @param ButtonColor $color |
129 | 129 | * @param string $attributes |
130 | 130 | */ |
131 | - public function addIndexActionButton($label, $actionURL, $fontAwesome_icon=null, $color=null, $attributes = null) |
|
131 | + public function addIndexActionButton($label, $actionURL, $fontAwesome_icon = null, $color = null, $attributes = null) |
|
132 | 132 | { |
133 | - $color = ($color)?:ButtonColor::DARK_BLUE; |
|
133 | + $color = ($color) ?: ButtonColor::DARK_BLUE; |
|
134 | 134 | |
135 | 135 | $model = new IndexActionButtonModel(); |
136 | 136 | $model->setLabel($label); |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | * @param $fontAwesome_icon |
186 | 186 | * @param ButtonColor|string $color |
187 | 187 | */ |
188 | - public function addActionButton($label, $url_target, $condition_callback=null, $fontAwesome_icon=null, $color=null, $confirmation = false) |
|
188 | + public function addActionButton($label, $url_target, $condition_callback = null, $fontAwesome_icon = null, $color = null, $confirmation = false) |
|
189 | 189 | { |
190 | 190 | $new = new AddActionButtonModel(); |
191 | 191 | $new->setLabel($label); |
192 | - $new->setIcon($fontAwesome_icon?:"fa fa-bars"); |
|
193 | - $new->setColor($color?:"primary"); |
|
192 | + $new->setIcon($fontAwesome_icon ?: "fa fa-bars"); |
|
193 | + $new->setColor($color ?: "primary"); |
|
194 | 194 | $new->setUrl($url_target); |
195 | 195 | $new->setCondition($condition_callback); |
196 | 196 | $new->setConfirmation($confirmation); |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | |
27 | 27 | public function __call($method, $parameters) |
28 | 28 | { |
29 | - if($method == "getData") { |
|
29 | + if ($method == "getData") { |
|
30 | 30 | $key = $parameters[0]; |
31 | - if(isset($this->data[$key])) { |
|
31 | + if (isset($this->data[$key])) { |
|
32 | 32 | return $this->data[$key]; |
33 | - }else{ |
|
33 | + } else { |
|
34 | 34 | return null; |
35 | 35 | } |
36 | - }else{ |
|
36 | + } else { |
|
37 | 37 | return null; |
38 | 38 | } |
39 | 39 | } |
@@ -48,19 +48,19 @@ discard block |
||
48 | 48 | |
49 | 49 | $query->addSelect($this->data['table'].'.'.cb()->pk($this->data['table']).' as primary_key'); |
50 | 50 | |
51 | - if(isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) |
|
51 | + if (isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) |
|
52 | 52 | { |
53 | 53 | $query = call_user_func($this->data['hook_query_index'], $query); |
54 | 54 | } |
55 | 55 | |
56 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
57 | - if($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
56 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
57 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
58 | 58 | $query->whereNull($this->data['table'].'.deleted_at'); |
59 | 59 | } |
60 | 60 | |
61 | 61 | |
62 | - if(isset($joins)) { |
|
63 | - foreach($joins as $join) |
|
62 | + if (isset($joins)) { |
|
63 | + foreach ($joins as $join) |
|
64 | 64 | { |
65 | 65 | $query->join($join['target_table'], |
66 | 66 | $join['target_table_primary'], |
@@ -70,31 +70,31 @@ discard block |
||
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | - foreach($columns as $column) { |
|
73 | + foreach ($columns as $column) { |
|
74 | 74 | /** @var ColumnModel $column */ |
75 | - if(strpos($column->getField(),".") === false) { |
|
75 | + if (strpos($column->getField(), ".") === false) { |
|
76 | 76 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
77 | - }else{ |
|
77 | + } else { |
|
78 | 78 | $query->addSelect($column->getField()); |
79 | 79 | } |
80 | 80 | |
81 | 81 | $query = getTypeHook($column->getType())->query($query, $column); |
82 | 82 | } |
83 | 83 | |
84 | - if(request()->has('q')) |
|
84 | + if (request()->has('q')) |
|
85 | 85 | { |
86 | - if(isset($this->data['hook_search_query'])) { |
|
86 | + if (isset($this->data['hook_search_query'])) { |
|
87 | 87 | $query = call_user_func($this->data['hook_search_query'], $query); |
88 | - }else{ |
|
89 | - $query->where(function ($where) use ($columns) { |
|
88 | + } else { |
|
89 | + $query->where(function($where) use ($columns) { |
|
90 | 90 | /** |
91 | 91 | * @var $where Builder |
92 | 92 | */ |
93 | - foreach($columns as $column) |
|
93 | + foreach ($columns as $column) |
|
94 | 94 | { |
95 | - if(strpos($column->getField(),".") === false) { |
|
95 | + if (strpos($column->getField(), ".") === false) { |
|
96 | 96 | $field = $this->data['table'].'.'.$column->getField(); |
97 | - }else{ |
|
97 | + } else { |
|
98 | 98 | $field = $column->getField(); |
99 | 99 | } |
100 | 100 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -103,17 +103,17 @@ discard block |
||
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | - if(isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) { |
|
106 | + if (isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) { |
|
107 | 107 | $query = call_user_func($this->data['hook_query_index'], $query); |
108 | 108 | } |
109 | 109 | |
110 | 110 | |
111 | - if(request()->has(['order_by','order_sort'])) |
|
111 | + if (request()->has(['order_by', 'order_sort'])) |
|
112 | 112 | { |
113 | - if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
|
113 | + if (in_array(request('order_by'), columnSingleton()->getColumnNameOnly())) { |
|
114 | 114 | $query->orderBy(request('order_by'), request('order_sort')); |
115 | 115 | } |
116 | - }else{ |
|
116 | + } else { |
|
117 | 117 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
118 | 118 | } |
119 | 119 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | public function getIndex() |
124 | 124 | { |
125 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
125 | + if (!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
126 | 126 | |
127 | 127 | $query = $this->repository(); |
128 | 128 | $result = $query->paginate(20); |
@@ -137,51 +137,51 @@ discard block |
||
137 | 137 | */ |
138 | 138 | private function validation() |
139 | 139 | { |
140 | - if(isset($this->data['validation'])) { |
|
140 | + if (isset($this->data['validation'])) { |
|
141 | 141 | $validator = Validator::make(request()->all(), @$this->data['validation'], @$this->data['validation_messages']); |
142 | 142 | if ($validator->fails()) { |
143 | 143 | $message = $validator->messages(); |
144 | 144 | $message_all = $message->all(); |
145 | - throw new CBValidationException(implode(', ',$message_all)); |
|
145 | + throw new CBValidationException(implode(', ', $message_all)); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | 150 | public function getAdd() |
151 | 151 | { |
152 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
152 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
153 | 153 | |
154 | 154 | $data = []; |
155 | 155 | $data['page_title'] = $this->data['page_title'].' : Add'; |
156 | 156 | $data['action_url'] = module()->addSaveURL(); |
157 | - return view('crudbooster::module.form.form',array_merge($data, $this->data)); |
|
157 | + return view('crudbooster::module.form.form', array_merge($data, $this->data)); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | public function postAddSave() |
161 | 161 | { |
162 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
162 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
163 | 163 | |
164 | 164 | try { |
165 | 165 | $this->validation(); |
166 | 166 | columnSingleton()->valueAssignment(); |
167 | 167 | $data = columnSingleton()->getAssignmentData(); |
168 | 168 | |
169 | - if(Schema::hasColumn($this->data['table'], 'created_at')) { |
|
169 | + if (Schema::hasColumn($this->data['table'], 'created_at')) { |
|
170 | 170 | $data['created_at'] = date('Y-m-d H:i:s'); |
171 | 171 | } |
172 | 172 | |
173 | 173 | $id = DB::table($this->data['table'])->insertGetId($data); |
174 | 174 | |
175 | - if(isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
175 | + if (isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
176 | 176 | call_user_func($this->data['hook_after_insert'], $id); |
177 | 177 | } |
178 | 178 | |
179 | 179 | } catch (CBValidationException $e) { |
180 | 180 | Log::debug($e); |
181 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
181 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
182 | 182 | } catch (\Exception $e) { |
183 | 183 | Log::error($e); |
184 | - return cb()->redirectBack($e->getMessage(),'warning'); |
|
184 | + return cb()->redirectBack($e->getMessage(), 'warning'); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | if (request('submit') == trans('crudbooster.button_save_more')) { |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | |
194 | 194 | public function getEdit($id) |
195 | 195 | { |
196 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
196 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
197 | 197 | |
198 | 198 | $data = []; |
199 | 199 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -204,17 +204,17 @@ discard block |
||
204 | 204 | |
205 | 205 | public function postEditSave($id) |
206 | 206 | { |
207 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
207 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
208 | 208 | |
209 | 209 | try { |
210 | 210 | $this->validation(); |
211 | 211 | columnSingleton()->valueAssignment(); |
212 | 212 | $data = columnSingleton()->getAssignmentData(); |
213 | - if(Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
213 | + if (Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
214 | 214 | $data['updated_at'] = date('Y-m-d H:i:s'); |
215 | 215 | } |
216 | 216 | |
217 | - if(isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
217 | + if (isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
218 | 218 | call_user_func($this->data['hook_before_update'], $id); |
219 | 219 | } |
220 | 220 | |
@@ -222,16 +222,16 @@ discard block |
||
222 | 222 | ->where(cb()->pk($this->data['table']), $id) |
223 | 223 | ->update($data); |
224 | 224 | |
225 | - if(isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
225 | + if (isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
226 | 226 | call_user_func($this->data['hook_after_update'], $id); |
227 | 227 | } |
228 | 228 | |
229 | 229 | } catch (CBValidationException $e) { |
230 | 230 | Log::debug($e); |
231 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
231 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
232 | 232 | } catch (\Exception $e) { |
233 | 233 | Log::error($e); |
234 | - return cb()->redirectBack($e->getMessage(),'warning'); |
|
234 | + return cb()->redirectBack($e->getMessage(), 'warning'); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
@@ -244,15 +244,15 @@ discard block |
||
244 | 244 | |
245 | 245 | public function getDelete($id) |
246 | 246 | { |
247 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
247 | + if (!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
248 | 248 | |
249 | - if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
249 | + if (isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
250 | 250 | call_user_func($this->data['hook_before_delete'], $id); |
251 | 251 | } |
252 | 252 | |
253 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
253 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
254 | 254 | |
255 | - if ($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
255 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
256 | 256 | DB::table($this->data['table']) |
257 | 257 | ->where(getPrimaryKey($this->data['table']), $id) |
258 | 258 | ->update(['deleted_at' => date('Y-m-d H:i:s')]); |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | ->delete(); |
263 | 263 | } |
264 | 264 | |
265 | - if(isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
265 | + if (isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
266 | 266 | call_user_func($this->data['hook_after_delete'], $id); |
267 | 267 | } |
268 | 268 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | |
272 | 272 | public function getDetail($id) |
273 | 273 | { |
274 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
274 | + if (!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
275 | 275 | |
276 | 276 | $data = []; |
277 | 277 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -281,21 +281,21 @@ discard block |
||
281 | 281 | |
282 | 282 | public function postUploadImage() |
283 | 283 | { |
284 | - if(auth()->guest()) return redirect(cb()->getLoginUrl()); |
|
284 | + if (auth()->guest()) return redirect(cb()->getLoginUrl()); |
|
285 | 285 | |
286 | 286 | $file = null; |
287 | 287 | try { |
288 | 288 | |
289 | 289 | cb()->validation([ |
290 | - 'userfile' => 'required|mimes:' . implode(",",config('crudbooster.UPLOAD_IMAGE_EXTENSION_ALLOWED')) |
|
290 | + 'userfile' => 'required|mimes:'.implode(",", config('crudbooster.UPLOAD_IMAGE_EXTENSION_ALLOWED')) |
|
291 | 291 | ]); |
292 | 292 | |
293 | 293 | $file = cb()->uploadFile('userfile', true); |
294 | 294 | |
295 | 295 | } catch (CBValidationException $e) { |
296 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
296 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
297 | 297 | } catch (\Exception $e) { |
298 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
298 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | return response()->json([ |
@@ -308,21 +308,21 @@ discard block |
||
308 | 308 | |
309 | 309 | public function postUploadFile() |
310 | 310 | { |
311 | - if(auth()->guest()) return redirect(cb()->getLoginUrl()); |
|
311 | + if (auth()->guest()) return redirect(cb()->getLoginUrl()); |
|
312 | 312 | |
313 | 313 | $file = null; |
314 | 314 | try { |
315 | 315 | |
316 | 316 | cb()->validation([ |
317 | - 'userfile' => 'required|mimes:' . implode(",",config('crudbooster.UPLOAD_FILE_EXTENSION_ALLOWED')) |
|
317 | + 'userfile' => 'required|mimes:'.implode(",", config('crudbooster.UPLOAD_FILE_EXTENSION_ALLOWED')) |
|
318 | 318 | ]); |
319 | 319 | |
320 | 320 | $file = cb()->uploadFile('userfile', true); |
321 | 321 | |
322 | 322 | } catch (CBValidationException $e) { |
323 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
323 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
324 | 324 | } catch (\Exception $e) { |
325 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
325 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | return response()->json([ |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | $key = $parameters[0]; |
31 | 31 | if(isset($this->data[$key])) { |
32 | 32 | return $this->data[$key]; |
33 | - }else{ |
|
33 | + } else{ |
|
34 | 34 | return null; |
35 | 35 | } |
36 | - }else{ |
|
36 | + } else{ |
|
37 | 37 | return null; |
38 | 38 | } |
39 | 39 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | /** @var ColumnModel $column */ |
75 | 75 | if(strpos($column->getField(),".") === false) { |
76 | 76 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
77 | - }else{ |
|
77 | + } else{ |
|
78 | 78 | $query->addSelect($column->getField()); |
79 | 79 | } |
80 | 80 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | { |
86 | 86 | if(isset($this->data['hook_search_query'])) { |
87 | 87 | $query = call_user_func($this->data['hook_search_query'], $query); |
88 | - }else{ |
|
88 | + } else{ |
|
89 | 89 | $query->where(function ($where) use ($columns) { |
90 | 90 | /** |
91 | 91 | * @var $where Builder |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | { |
95 | 95 | if(strpos($column->getField(),".") === false) { |
96 | 96 | $field = $this->data['table'].'.'.$column->getField(); |
97 | - }else{ |
|
97 | + } else{ |
|
98 | 98 | $field = $column->getField(); |
99 | 99 | } |
100 | 100 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
114 | 114 | $query->orderBy(request('order_by'), request('order_sort')); |
115 | 115 | } |
116 | - }else{ |
|
116 | + } else{ |
|
117 | 117 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
118 | 118 | } |
119 | 119 | |
@@ -122,7 +122,9 @@ discard block |
||
122 | 122 | |
123 | 123 | public function getIndex() |
124 | 124 | { |
125 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
125 | + if(!module()->canBrowse()) { |
|
126 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
127 | + } |
|
126 | 128 | |
127 | 129 | $query = $this->repository(); |
128 | 130 | $result = $query->paginate(20); |
@@ -149,7 +151,9 @@ discard block |
||
149 | 151 | |
150 | 152 | public function getAdd() |
151 | 153 | { |
152 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
154 | + if(!module()->canCreate()) { |
|
155 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
156 | + } |
|
153 | 157 | |
154 | 158 | $data = []; |
155 | 159 | $data['page_title'] = $this->data['page_title'].' : Add'; |
@@ -159,7 +163,9 @@ discard block |
||
159 | 163 | |
160 | 164 | public function postAddSave() |
161 | 165 | { |
162 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
166 | + if(!module()->canCreate()) { |
|
167 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
168 | + } |
|
163 | 169 | |
164 | 170 | try { |
165 | 171 | $this->validation(); |
@@ -193,7 +199,9 @@ discard block |
||
193 | 199 | |
194 | 200 | public function getEdit($id) |
195 | 201 | { |
196 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
202 | + if(!module()->canUpdate()) { |
|
203 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
204 | + } |
|
197 | 205 | |
198 | 206 | $data = []; |
199 | 207 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -204,7 +212,9 @@ discard block |
||
204 | 212 | |
205 | 213 | public function postEditSave($id) |
206 | 214 | { |
207 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
215 | + if(!module()->canUpdate()) { |
|
216 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
217 | + } |
|
208 | 218 | |
209 | 219 | try { |
210 | 220 | $this->validation(); |
@@ -244,7 +254,9 @@ discard block |
||
244 | 254 | |
245 | 255 | public function getDelete($id) |
246 | 256 | { |
247 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
257 | + if(!module()->canDelete()) { |
|
258 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
259 | + } |
|
248 | 260 | |
249 | 261 | if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
250 | 262 | call_user_func($this->data['hook_before_delete'], $id); |
@@ -271,7 +283,9 @@ discard block |
||
271 | 283 | |
272 | 284 | public function getDetail($id) |
273 | 285 | { |
274 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
286 | + if(!module()->canRead()) { |
|
287 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
288 | + } |
|
275 | 289 | |
276 | 290 | $data = []; |
277 | 291 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -281,7 +295,9 @@ discard block |
||
281 | 295 | |
282 | 296 | public function postUploadImage() |
283 | 297 | { |
284 | - if(auth()->guest()) return redirect(cb()->getLoginUrl()); |
|
298 | + if(auth()->guest()) { |
|
299 | + return redirect(cb()->getLoginUrl()); |
|
300 | + } |
|
285 | 301 | |
286 | 302 | $file = null; |
287 | 303 | try { |
@@ -308,7 +324,9 @@ discard block |
||
308 | 324 | |
309 | 325 | public function postUploadFile() |
310 | 326 | { |
311 | - if(auth()->guest()) return redirect(cb()->getLoginUrl()); |
|
327 | + if(auth()->guest()) { |
|
328 | + return redirect(cb()->getLoginUrl()); |
|
329 | + } |
|
312 | 330 | |
313 | 331 | $file = null; |
314 | 332 | try { |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | public function detailRender($row, $column) |
29 | 29 | { |
30 | 30 | $column->setValue($row->{ $column->getField() }); |
31 | - return view("types::image.detail",[ |
|
31 | + return view("types::image.detail", [ |
|
32 | 32 | 'row'=>$row, |
33 | 33 | 'column'=>$column |
34 | 34 | ]); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | public function indexRender($row, $column) |
38 | 38 | { |
39 | 39 | $column->setValue($row->{ $column->getField() }); |
40 | - return view("types::image.index",[ |
|
40 | + return view("types::image.index", [ |
|
41 | 41 | 'row'=>$row, |
42 | 42 | 'column'=>$column |
43 | 43 | ]); |
@@ -27,7 +27,7 @@ |
||
27 | 27 | public function detailRender($row, $column) |
28 | 28 | { |
29 | 29 | $column->setValue($row->{ $column->getField() }); |
30 | - return view("types::file.detail",[ |
|
30 | + return view("types::file.detail", [ |
|
31 | 31 | 'row'=>$row, |
32 | 32 | 'column'=>$column |
33 | 33 | ]); |