@@ -42,17 +42,17 @@ discard block |
||
| 42 | 42 | public function valueAssignment($data_row = null) { |
| 43 | 43 | foreach ($this->getColumns() as $index=>$column) { |
| 44 | 44 | |
| 45 | - if (! $column->getName()) { |
|
| 45 | + if (!$column->getName()) { |
|
| 46 | 46 | continue; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** @var ColumnModel $column */ |
| 50 | - if($data_row) { |
|
| 51 | - $value = (isset($data_row->{$column->getField()}))?$data_row->{ $column->getField() }:null; |
|
| 52 | - }else{ |
|
| 50 | + if ($data_row) { |
|
| 51 | + $value = (isset($data_row->{$column->getField()})) ? $data_row->{ $column->getField() }:null; |
|
| 52 | + } else { |
|
| 53 | 53 | $value = request($column->getName()); |
| 54 | 54 | |
| 55 | - if(!$value && $column->getDefaultValue()) { |
|
| 55 | + if (!$value && $column->getDefaultValue()) { |
|
| 56 | 56 | $value = $column->getDefaultValue(); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -68,9 +68,9 @@ discard block |
||
| 68 | 68 | { |
| 69 | 69 | $data = $this->columns; |
| 70 | 70 | $newData = []; |
| 71 | - foreach($data as $i=>$item) { |
|
| 71 | + foreach ($data as $i=>$item) { |
|
| 72 | 72 | /** @var ColumnModel $item */ |
| 73 | - if($item->getShowIndex()) { |
|
| 73 | + if ($item->getShowIndex()) { |
|
| 74 | 74 | $newData[] = $item; |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -81,9 +81,9 @@ discard block |
||
| 81 | 81 | { |
| 82 | 82 | $data = $this->columns; |
| 83 | 83 | $newData = []; |
| 84 | - foreach($data as $i=>$item) { |
|
| 84 | + foreach ($data as $i=>$item) { |
|
| 85 | 85 | /** @var ColumnModel $item */ |
| 86 | - if($item->getShowAdd() || $item->getShowEdit()) { |
|
| 86 | + if ($item->getShowAdd() || $item->getShowEdit()) { |
|
| 87 | 87 | $newData[] = $item; |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | { |
| 95 | 95 | $data = $this->columns; |
| 96 | 96 | $newData = []; |
| 97 | - foreach($data as $i=>$item) { |
|
| 97 | + foreach ($data as $i=>$item) { |
|
| 98 | 98 | /** @var ColumnModel $item */ |
| 99 | - if($item->getShowEdit()) { |
|
| 99 | + if ($item->getShowEdit()) { |
|
| 100 | 100 | $newData[] = $item; |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | { |
| 108 | 108 | $data = $this->columns; |
| 109 | 109 | $newData = []; |
| 110 | - foreach($data as $i=>$item) { |
|
| 110 | + foreach ($data as $i=>$item) { |
|
| 111 | 111 | /** @var ColumnModel $item */ |
| 112 | - if($item->getShowAdd()) { |
|
| 112 | + if ($item->getShowAdd()) { |
|
| 113 | 113 | $newData[] = $item; |
| 114 | 114 | } |
| 115 | 115 | } |
@@ -120,9 +120,9 @@ discard block |
||
| 120 | 120 | { |
| 121 | 121 | $data = $this->columns; |
| 122 | 122 | $newData = []; |
| 123 | - foreach($data as $i=>$item) { |
|
| 123 | + foreach ($data as $i=>$item) { |
|
| 124 | 124 | /** @var ColumnModel $item */ |
| 125 | - if($item->getShowDetail()) { |
|
| 125 | + if ($item->getShowDetail()) { |
|
| 126 | 126 | $newData[] = $item; |
| 127 | 127 | } |
| 128 | 128 | } |
@@ -132,14 +132,14 @@ discard block |
||
| 132 | 132 | public function getAssignmentData() |
| 133 | 133 | { |
| 134 | 134 | $data = []; |
| 135 | - foreach($this->columns as $column) { |
|
| 135 | + foreach ($this->columns as $column) { |
|
| 136 | 136 | /** @var ColumnModel $column */ |
| 137 | 137 | |
| 138 | - if(is_array($column->getValue())) { |
|
| 139 | - foreach($column->getValue() as $key=>$val) { |
|
| 138 | + if (is_array($column->getValue())) { |
|
| 139 | + foreach ($column->getValue() as $key=>$val) { |
|
| 140 | 140 | $data[$key] = $val; |
| 141 | 141 | } |
| 142 | - }else{ |
|
| 142 | + } else { |
|
| 143 | 143 | $data[$column->getField()] = $column->getValue(); |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -149,10 +149,10 @@ discard block |
||
| 149 | 149 | public function removeColumn($label_or_name) |
| 150 | 150 | { |
| 151 | 151 | $data = $this->getColumns(); |
| 152 | - foreach($data as $i=>$d) |
|
| 152 | + foreach ($data as $i=>$d) |
|
| 153 | 153 | { |
| 154 | 154 | /** @var ColumnModel $d */ |
| 155 | - if($d->getLabel() == $label_or_name || $d->getName() == $label_or_name) { |
|
| 155 | + if ($d->getLabel() == $label_or_name || $d->getName() == $label_or_name) { |
|
| 156 | 156 | unset($data[$i]); |
| 157 | 157 | } |
| 158 | 158 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | public function getColumnNameOnly() |
| 163 | 163 | { |
| 164 | 164 | $result = []; |
| 165 | - foreach($this->columns as $column) { |
|
| 165 | + foreach ($this->columns as $column) { |
|
| 166 | 166 | /** @var ColumnModel $column */ |
| 167 | 167 | $result[] = $column->getName(); |
| 168 | 168 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | /** @var ColumnModel $column */ |
| 50 | 50 | if($data_row) { |
| 51 | 51 | $value = (isset($data_row->{$column->getField()}))?$data_row->{ $column->getField() }:null; |
| 52 | - }else{ |
|
| 52 | + } else{ |
|
| 53 | 53 | $value = request($column->getName()); |
| 54 | 54 | |
| 55 | 55 | if(!$value && $column->getDefaultValue()) { |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | foreach($column->getValue() as $key=>$val) { |
| 140 | 140 | $data[$key] = $val; |
| 141 | 141 | } |
| 142 | - }else{ |
|
| 142 | + } else{ |
|
| 143 | 143 | $data[$column->getField()] = $column->getValue(); |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | private function name($label, $name = null) |
| 20 | 20 | { |
| 21 | - return (!$name)?strtolower(slug($label,"_")):$name; |
|
| 21 | + return (!$name) ?strtolower(slug($label, "_")) : $name; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -39,8 +39,8 @@ discard block |
||
| 39 | 39 | $model->setShowAdd(true); |
| 40 | 40 | $model->setShowEdit(true); |
| 41 | 41 | $model->setShowDetail(true); |
| 42 | - $model->setIndexDisplayTransform(function ($value, $row) { return $value; }); |
|
| 43 | - $model->setDetailDisplayTransform(function ($value, $row) { return $value; }); |
|
| 42 | + $model->setIndexDisplayTransform(function($value, $row) { return $value; }); |
|
| 43 | + $model->setDetailDisplayTransform(function($value, $row) { return $value; }); |
|
| 44 | 44 | return $model; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -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,12 +70,12 @@ 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($column->getType() != "custom") { |
|
| 76 | - if(strpos($column->getField(),".") === false) { |
|
| 75 | + if ($column->getType() != "custom") { |
|
| 76 | + if (strpos($column->getField(), ".") === false) { |
|
| 77 | 77 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
| 78 | - }else{ |
|
| 78 | + } else { |
|
| 79 | 79 | $query->addSelect($column->getField()); |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -83,20 +83,20 @@ discard block |
||
| 83 | 83 | $query = getTypeHook($column->getType())->query($query, $column); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if(request()->has('q')) |
|
| 86 | + if (request()->has('q')) |
|
| 87 | 87 | { |
| 88 | - if(isset($this->data['hook_search_query'])) { |
|
| 88 | + if (isset($this->data['hook_search_query'])) { |
|
| 89 | 89 | $query = call_user_func($this->data['hook_search_query'], $query); |
| 90 | - }else{ |
|
| 91 | - $query->where(function ($where) use ($columns) { |
|
| 90 | + } else { |
|
| 91 | + $query->where(function($where) use ($columns) { |
|
| 92 | 92 | /** |
| 93 | 93 | * @var $where Builder |
| 94 | 94 | */ |
| 95 | - foreach($columns as $column) |
|
| 95 | + foreach ($columns as $column) |
|
| 96 | 96 | { |
| 97 | - if(strpos($column->getField(),".") === false) { |
|
| 97 | + if (strpos($column->getField(), ".") === false) { |
|
| 98 | 98 | $field = $this->data['table'].'.'.$column->getField(); |
| 99 | - }else{ |
|
| 99 | + } else { |
|
| 100 | 100 | $field = $column->getField(); |
| 101 | 101 | } |
| 102 | 102 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -105,17 +105,17 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if(isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) { |
|
| 108 | + if (isset($this->data['hook_query_index']) && is_callable($this->data['hook_query_index'])) { |
|
| 109 | 109 | $query = call_user_func($this->data['hook_query_index'], $query); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | |
| 113 | - if(request()->has(['order_by','order_sort'])) |
|
| 113 | + if (request()->has(['order_by', 'order_sort'])) |
|
| 114 | 114 | { |
| 115 | - if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
|
| 115 | + if (in_array(request('order_by'), columnSingleton()->getColumnNameOnly())) { |
|
| 116 | 116 | $query->orderBy(request('order_by'), request('order_sort')); |
| 117 | 117 | } |
| 118 | - }else{ |
|
| 118 | + } else { |
|
| 119 | 119 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
| 120 | 120 | } |
| 121 | 121 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | public function getIndex() |
| 126 | 126 | { |
| 127 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 127 | + if (!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
| 128 | 128 | |
| 129 | 129 | $query = $this->repository(); |
| 130 | 130 | $result = $query->paginate(20); |
@@ -139,29 +139,29 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | private function validation() |
| 141 | 141 | { |
| 142 | - if(isset($this->data['validation'])) { |
|
| 142 | + if (isset($this->data['validation'])) { |
|
| 143 | 143 | $validator = Validator::make(request()->all(), @$this->data['validation'], @$this->data['validation_messages']); |
| 144 | 144 | if ($validator->fails()) { |
| 145 | 145 | $message = $validator->messages(); |
| 146 | 146 | $message_all = $message->all(); |
| 147 | - throw new CBValidationException(implode(', ',$message_all)); |
|
| 147 | + throw new CBValidationException(implode(', ', $message_all)); |
|
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | public function getAdd() |
| 153 | 153 | { |
| 154 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 154 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
| 155 | 155 | |
| 156 | 156 | $data = []; |
| 157 | 157 | $data['page_title'] = $this->data['page_title'].' : Add'; |
| 158 | 158 | $data['action_url'] = module()->addSaveURL(); |
| 159 | - return view('crudbooster::module.form.form',array_merge($data, $this->data)); |
|
| 159 | + return view('crudbooster::module.form.form', array_merge($data, $this->data)); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | public function postAddSave() |
| 163 | 163 | { |
| 164 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 164 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
| 165 | 165 | |
| 166 | 166 | try { |
| 167 | 167 | $this->validation(); |
@@ -169,24 +169,24 @@ discard block |
||
| 169 | 169 | $data = columnSingleton()->getAssignmentData(); |
| 170 | 170 | |
| 171 | 171 | //Clear data from Primary Key |
| 172 | - unset($data[ cb()->pk($this->data['table']) ]); |
|
| 172 | + unset($data[cb()->pk($this->data['table'])]); |
|
| 173 | 173 | |
| 174 | - if(Schema::hasColumn($this->data['table'], 'created_at')) { |
|
| 174 | + if (Schema::hasColumn($this->data['table'], 'created_at')) { |
|
| 175 | 175 | $data['created_at'] = date('Y-m-d H:i:s'); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | $id = DB::table($this->data['table'])->insertGetId($data); |
| 179 | 179 | |
| 180 | - if(isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
| 180 | + if (isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
| 181 | 181 | call_user_func($this->data['hook_after_insert'], $id); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | } catch (CBValidationException $e) { |
| 185 | 185 | Log::debug($e); |
| 186 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
| 186 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
| 187 | 187 | } catch (\Exception $e) { |
| 188 | 188 | Log::error($e); |
| 189 | - return cb()->redirectBack($e->getMessage(),'warning'); |
|
| 189 | + return cb()->redirectBack($e->getMessage(), 'warning'); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | if (request('submit') == trans('crudbooster.button_save_more')) { |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | public function getEdit($id) |
| 200 | 200 | { |
| 201 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 201 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
| 202 | 202 | |
| 203 | 203 | $data = []; |
| 204 | 204 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | public function postEditSave($id) |
| 211 | 211 | { |
| 212 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 212 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
| 213 | 213 | |
| 214 | 214 | try { |
| 215 | 215 | $this->validation(); |
@@ -217,13 +217,13 @@ discard block |
||
| 217 | 217 | $data = columnSingleton()->getAssignmentData(); |
| 218 | 218 | |
| 219 | 219 | //Clear data from Primary Key |
| 220 | - unset($data[ cb()->pk($this->data['table']) ]); |
|
| 220 | + unset($data[cb()->pk($this->data['table'])]); |
|
| 221 | 221 | |
| 222 | - if(Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
| 222 | + if (Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
| 223 | 223 | $data['updated_at'] = date('Y-m-d H:i:s'); |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - if(isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
| 226 | + if (isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
| 227 | 227 | call_user_func($this->data['hook_before_update'], $id); |
| 228 | 228 | } |
| 229 | 229 | |
@@ -231,16 +231,16 @@ discard block |
||
| 231 | 231 | ->where(cb()->pk($this->data['table']), $id) |
| 232 | 232 | ->update($data); |
| 233 | 233 | |
| 234 | - if(isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
| 234 | + if (isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
| 235 | 235 | call_user_func($this->data['hook_after_update'], $id); |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | } catch (CBValidationException $e) { |
| 239 | 239 | Log::debug($e); |
| 240 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
| 240 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
| 241 | 241 | } catch (\Exception $e) { |
| 242 | 242 | Log::error($e); |
| 243 | - return cb()->redirectBack($e->getMessage(),'warning'); |
|
| 243 | + return cb()->redirectBack($e->getMessage(), 'warning'); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | |
@@ -253,15 +253,15 @@ discard block |
||
| 253 | 253 | |
| 254 | 254 | public function getDelete($id) |
| 255 | 255 | { |
| 256 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 256 | + if (!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
| 257 | 257 | |
| 258 | - if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
| 258 | + if (isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
| 259 | 259 | call_user_func($this->data['hook_before_delete'], $id); |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
| 262 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
| 263 | 263 | |
| 264 | - if ($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
| 264 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
| 265 | 265 | DB::table($this->data['table']) |
| 266 | 266 | ->where(getPrimaryKey($this->data['table']), $id) |
| 267 | 267 | ->update(['deleted_at' => date('Y-m-d H:i:s')]); |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | ->delete(); |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if(isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
| 274 | + if (isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
| 275 | 275 | call_user_func($this->data['hook_after_delete'], $id); |
| 276 | 276 | } |
| 277 | 277 | |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | |
| 281 | 281 | public function getDetail($id) |
| 282 | 282 | { |
| 283 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 283 | + if (!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(), "You do not have a privilege access to this area"); |
|
| 284 | 284 | |
| 285 | 285 | $data = []; |
| 286 | 286 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -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 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | if($column->getType() != "custom") { |
| 76 | 76 | if(strpos($column->getField(),".") === false) { |
| 77 | 77 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
| 78 | - }else{ |
|
| 78 | + } else{ |
|
| 79 | 79 | $query->addSelect($column->getField()); |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | { |
| 88 | 88 | if(isset($this->data['hook_search_query'])) { |
| 89 | 89 | $query = call_user_func($this->data['hook_search_query'], $query); |
| 90 | - }else{ |
|
| 90 | + } else{ |
|
| 91 | 91 | $query->where(function ($where) use ($columns) { |
| 92 | 92 | /** |
| 93 | 93 | * @var $where Builder |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | { |
| 97 | 97 | if(strpos($column->getField(),".") === false) { |
| 98 | 98 | $field = $this->data['table'].'.'.$column->getField(); |
| 99 | - }else{ |
|
| 99 | + } else{ |
|
| 100 | 100 | $field = $column->getField(); |
| 101 | 101 | } |
| 102 | 102 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
| 116 | 116 | $query->orderBy(request('order_by'), request('order_sort')); |
| 117 | 117 | } |
| 118 | - }else{ |
|
| 118 | + } else{ |
|
| 119 | 119 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
| 120 | 120 | } |
| 121 | 121 | |
@@ -124,7 +124,9 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | public function getIndex() |
| 126 | 126 | { |
| 127 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 127 | + if(!module()->canBrowse()) { |
|
| 128 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 129 | + } |
|
| 128 | 130 | |
| 129 | 131 | $query = $this->repository(); |
| 130 | 132 | $result = $query->paginate(20); |
@@ -151,7 +153,9 @@ discard block |
||
| 151 | 153 | |
| 152 | 154 | public function getAdd() |
| 153 | 155 | { |
| 154 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 156 | + if(!module()->canCreate()) { |
|
| 157 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 158 | + } |
|
| 155 | 159 | |
| 156 | 160 | $data = []; |
| 157 | 161 | $data['page_title'] = $this->data['page_title'].' : Add'; |
@@ -161,7 +165,9 @@ discard block |
||
| 161 | 165 | |
| 162 | 166 | public function postAddSave() |
| 163 | 167 | { |
| 164 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 168 | + if(!module()->canCreate()) { |
|
| 169 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 170 | + } |
|
| 165 | 171 | |
| 166 | 172 | try { |
| 167 | 173 | $this->validation(); |
@@ -198,7 +204,9 @@ discard block |
||
| 198 | 204 | |
| 199 | 205 | public function getEdit($id) |
| 200 | 206 | { |
| 201 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 207 | + if(!module()->canUpdate()) { |
|
| 208 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 209 | + } |
|
| 202 | 210 | |
| 203 | 211 | $data = []; |
| 204 | 212 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -209,7 +217,9 @@ discard block |
||
| 209 | 217 | |
| 210 | 218 | public function postEditSave($id) |
| 211 | 219 | { |
| 212 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 220 | + if(!module()->canUpdate()) { |
|
| 221 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 222 | + } |
|
| 213 | 223 | |
| 214 | 224 | try { |
| 215 | 225 | $this->validation(); |
@@ -253,7 +263,9 @@ discard block |
||
| 253 | 263 | |
| 254 | 264 | public function getDelete($id) |
| 255 | 265 | { |
| 256 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 266 | + if(!module()->canDelete()) { |
|
| 267 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 268 | + } |
|
| 257 | 269 | |
| 258 | 270 | if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
| 259 | 271 | call_user_func($this->data['hook_before_delete'], $id); |
@@ -280,7 +292,9 @@ discard block |
||
| 280 | 292 | |
| 281 | 293 | public function getDetail($id) |
| 282 | 294 | { |
| 283 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 295 | + if(!module()->canRead()) { |
|
| 296 | + return cb()->redirect(cb()->getAdminUrl(),"You do not have a privilege access to this area"); |
|
| 297 | + } |
|
| 284 | 298 | |
| 285 | 299 | $data = []; |
| 286 | 300 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -26,12 +26,12 @@ |
||
| 26 | 26 | |
| 27 | 27 | public function indexRender($row, $column) |
| 28 | 28 | { |
| 29 | - return (isset($row->{$column->getField()}))?$row->{ $column->getField() }:null; |
|
| 29 | + return (isset($row->{$column->getField()})) ? $row->{ $column->getField() }:null; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | public function detailRender($row, $column) |
| 33 | 33 | { |
| 34 | - return (isset($row->{$column->getField()}))?$row->{ $column->getField() }:null; |
|
| 34 | + return (isset($row->{$column->getField()})) ? $row->{ $column->getField() }:null; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -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 | } |