@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | |
26 | 26 | $query->addSelect($this->data['table'].'.'.cb()->pk($this->data['table']).' as primary_key'); |
27 | 27 | |
28 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
29 | - if($softDelete === true && SchemaHelper::hasColumn($this->data['table'],'deleted_at')) { |
|
28 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
29 | + if ($softDelete === true && SchemaHelper::hasColumn($this->data['table'], 'deleted_at')) { |
|
30 | 30 | $query->whereNull($this->data['table'].'.deleted_at'); |
31 | 31 | } |
32 | 32 | |
33 | - if(isset($joins)) { |
|
34 | - foreach($joins as $join) |
|
33 | + if (isset($joins)) { |
|
34 | + foreach ($joins as $join) |
|
35 | 35 | { |
36 | 36 | $query->join($join['target_table'], |
37 | 37 | $join['target_table_primary'], |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | - foreach($columns as $column) { |
|
44 | + foreach ($columns as $column) { |
|
45 | 45 | /** @var ColumnModel $column */ |
46 | - if($column->getType() != "custom") { |
|
47 | - if(strpos($column->getField(),".") === false) { |
|
48 | - if(SchemaHelper::hasColumn($this->data['table'], $column->getField())) { |
|
46 | + if ($column->getType() != "custom") { |
|
47 | + if (strpos($column->getField(), ".") === false) { |
|
48 | + if (SchemaHelper::hasColumn($this->data['table'], $column->getField())) { |
|
49 | 49 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
50 | 50 | } |
51 | - }else{ |
|
51 | + } else { |
|
52 | 52 | $query->addSelect($column->getField()); |
53 | 53 | } |
54 | 54 | } |
@@ -57,27 +57,27 @@ discard block |
||
57 | 57 | $query = getTypeHook($column->getType())->query($query, $column); |
58 | 58 | |
59 | 59 | // Filter Query From Type |
60 | - $filterValue = request("filter_".slug($column->getFilterColumn(),"_")); |
|
61 | - if(is_array($filterValue) || sanitizeXSS($filterValue)) { |
|
60 | + $filterValue = request("filter_".slug($column->getFilterColumn(), "_")); |
|
61 | + if (is_array($filterValue) || sanitizeXSS($filterValue)) { |
|
62 | 62 | $query = getTypeHook($column->getType())->filterQuery($query, $column, $filterValue); |
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | - if(request()->has('q')) |
|
66 | + if (request()->has('q')) |
|
67 | 67 | { |
68 | 68 | $keyword = sanitizeXSS(request("q")); |
69 | - if(isset($this->data['hook_search_query'])) { |
|
69 | + if (isset($this->data['hook_search_query'])) { |
|
70 | 70 | $query = call_user_func($this->data['hook_search_query'], $query); |
71 | - }else{ |
|
72 | - $query->where(function ($where) use ($columns, $keyword) { |
|
71 | + } else { |
|
72 | + $query->where(function($where) use ($columns, $keyword) { |
|
73 | 73 | /** |
74 | 74 | * @var $where Builder |
75 | 75 | */ |
76 | - foreach($columns as $column) |
|
76 | + foreach ($columns as $column) |
|
77 | 77 | { |
78 | - if(strpos($column->getField(),".") === false) { |
|
78 | + if (strpos($column->getField(), ".") === false) { |
|
79 | 79 | $field = $this->data['table'].'.'.$column->getField(); |
80 | - }else{ |
|
80 | + } else { |
|
81 | 81 | $field = $column->getField(); |
82 | 82 | } |
83 | 83 | $where->orWhere($field, 'like', '%'.$keyword.'%'); |
@@ -90,36 +90,36 @@ discard block |
||
90 | 90 | /* |
91 | 91 | * This script to hanlde the callback inputed on this query method |
92 | 92 | */ |
93 | - if(isset($callback) && is_callable($callback)) { |
|
93 | + if (isset($callback) && is_callable($callback)) { |
|
94 | 94 | $query = call_user_func($callback, $query); |
95 | 95 | } |
96 | 96 | |
97 | - if(isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) { |
|
97 | + if (isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) { |
|
98 | 98 | $query = call_user_func($this->data['hook_index_query'], $query); |
99 | 99 | } |
100 | 100 | |
101 | 101 | |
102 | - if(request()->has(['order_by','order_sort'])) |
|
102 | + if (request()->has(['order_by', 'order_sort'])) |
|
103 | 103 | { |
104 | - $sort = (request("order_sort")=="asc")?"asc":"desc"; |
|
104 | + $sort = (request("order_sort") == "asc") ? "asc" : "desc"; |
|
105 | 105 | /* |
106 | 106 | * Check if order by contain "." it means {table}.{column} we have to parsing that |
107 | 107 | */ |
108 | - if(strpos(request("order_by"), ".")!==false) { |
|
109 | - $orderByTable = explode(".",request("order_by"))[0]; |
|
110 | - $orderByColumn = explode(".",request("order_by"))[1]; |
|
111 | - if(SchemaHelper::hasColumn($orderByTable, $orderByColumn)) { |
|
108 | + if (strpos(request("order_by"), ".") !== false) { |
|
109 | + $orderByTable = explode(".", request("order_by"))[0]; |
|
110 | + $orderByColumn = explode(".", request("order_by"))[1]; |
|
111 | + if (SchemaHelper::hasColumn($orderByTable, $orderByColumn)) { |
|
112 | 112 | $query->orderBy($orderByTable.".".$orderByColumn, $sort); |
113 | 113 | } |
114 | 114 | } else { |
115 | 115 | /* |
116 | 116 | * Check if order_by column in registered columns |
117 | 117 | */ |
118 | - if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
|
118 | + if (in_array(request('order_by'), columnSingleton()->getColumnNameOnly())) { |
|
119 | 119 | $query->orderBy(request('order_by'), request('order_sort')); |
120 | 120 | } |
121 | 121 | } |
122 | - }else{ |
|
122 | + } else { |
|
123 | 123 | /* |
124 | 124 | * For default, query will be order by primary key as descending |
125 | 125 | */ |
@@ -24,7 +24,7 @@ |
||
24 | 24 | $data = ColumnSingleton()->getColumn($this->index); |
25 | 25 | $data->setFilterable($boolean); |
26 | 26 | $data->setFilterHelp($help_info); |
27 | - $data->setFilterPlaceholder($placeholder?:"Filter by ".$data->getLabel()); |
|
27 | + $data->setFilterPlaceholder($placeholder ?: "Filter by ".$data->getLabel()); |
|
28 | 28 | // Save back |
29 | 29 | columnSingleton()->setColumn($this->index, $data); |
30 | 30 |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | $data = new TextModel(); |
66 | 66 | $data = $this->setDefaultModelValue($data); |
67 | 67 | $data->setLabel($label); |
68 | - $data->setName($this->name($label,$name)); |
|
69 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
68 | + $data->setName($this->name($label, $name)); |
|
69 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
70 | 70 | $data->setOrderByColumn($this->table().".".$data->getField()); |
71 | 71 | $data->setFilterColumn($this->table().".".$data->getField()); |
72 | 72 | $data->setType("text"); |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | $data = new CheckboxModel(); |
84 | 84 | $data = $this->setDefaultModelValue($data); |
85 | 85 | $data->setLabel($label); |
86 | - $data->setName($this->name($label,$name)); |
|
87 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
86 | + $data->setName($this->name($label, $name)); |
|
87 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
88 | 88 | $data->setOrderByColumn($this->table().".".$data->getField()); |
89 | 89 | $data->setFilterColumn($this->table().".".$data->getField()); |
90 | 90 | $data->setType("checkbox"); |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | $data = new PasswordModel(); |
102 | 102 | $data = $this->setDefaultModelValue($data); |
103 | 103 | $data->setLabel($label); |
104 | - $data->setName($this->name($label,$name)); |
|
105 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
104 | + $data->setName($this->name($label, $name)); |
|
105 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
106 | 106 | $data->setOrderByColumn($this->table().".".$data->getField()); |
107 | 107 | $data->setFilterColumn($this->table().".".$data->getField()); |
108 | 108 | $data->setType("password"); |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | $data = new ImageModel(); |
122 | 122 | $data = $this->setDefaultModelValue($data); |
123 | 123 | $data->setLabel($label); |
124 | - $data->setName($this->name($label,$name)); |
|
125 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
124 | + $data->setName($this->name($label, $name)); |
|
125 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
126 | 126 | $data->setOrderByColumn($this->table().".".$data->getField()); |
127 | 127 | $data->setFilterColumn($this->table().".".$data->getField()); |
128 | 128 | $data->setType("image"); |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | $data = new TextAreaModel(); |
140 | 140 | $data = $this->setDefaultModelValue($data); |
141 | 141 | $data->setLabel($label); |
142 | - $data->setName($this->name($label,$name)); |
|
143 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
142 | + $data->setName($this->name($label, $name)); |
|
143 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
144 | 144 | $data->setOrderByColumn($this->table().".".$data->getField()); |
145 | 145 | $data->setFilterColumn($this->table().".".$data->getField()); |
146 | 146 | $data->setType("text_area"); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function addSelectTable($label, $name = null, $selectConfig) |
167 | 167 | { |
168 | - if(isset($selectConfig['table']) && |
|
168 | + if (isset($selectConfig['table']) && |
|
169 | 169 | isset($selectConfig['value_option']) && |
170 | 170 | isset($selectConfig['display_option'])) { |
171 | 171 | $this->index++; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $data = new SelectTableModel(); |
174 | 174 | $data = $this->setDefaultModelValue($data); |
175 | 175 | $data->setLabel($label); |
176 | - $data->setName($this->name($label,$name)); |
|
176 | + $data->setName($this->name($label, $name)); |
|
177 | 177 | $data->setField($this->name($label, $name)); |
178 | 178 | $data->setType("select_table"); |
179 | 179 | $data->setOrderByColumn($selectConfig['table'].".".$selectConfig["display_option"]); |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | columnSingleton()->setColumn($this->index, $data); |
182 | 182 | |
183 | 183 | $selectTable = new SelectTable($this->index); |
184 | - $selectTable->optionsFromTable($selectConfig['table'],$selectConfig['value_option'],$selectConfig['display_option'],@$selectConfig['sql_condition']); |
|
184 | + $selectTable->optionsFromTable($selectConfig['table'], $selectConfig['value_option'], $selectConfig['display_option'], @$selectConfig['sql_condition']); |
|
185 | 185 | |
186 | 186 | return $selectTable; |
187 | 187 | } else { |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $data = new SelectOptionModel(); |
197 | 197 | $data = $this->setDefaultModelValue($data); |
198 | 198 | $data->setLabel($label); |
199 | - $data->setName($this->name($label,$name)); |
|
199 | + $data->setName($this->name($label, $name)); |
|
200 | 200 | $data->setField($this->name($label, $name)); |
201 | 201 | $data->setOrderByColumn($this->table().".".$data->getField()); |
202 | 202 | $data->setFilterColumn($this->table().".".$data->getField()); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | |
207 | 207 | $selectOption = new SelectOption($this->index); |
208 | 208 | |
209 | - if($options) { |
|
209 | + if ($options) { |
|
210 | 210 | $selectOption->options($options); |
211 | 211 | } |
212 | 212 | |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | $data = new CustomModel(); |
222 | 222 | $data = $this->setDefaultModelValue($data); |
223 | 223 | $data->setLabel($label); |
224 | - $data->setName($this->name($label,$name)); |
|
225 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
224 | + $data->setName($this->name($label, $name)); |
|
225 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
226 | 226 | $data->setOrderByColumn($this->table().".".$data->getField()); |
227 | 227 | $data->setFilterColumn($this->table().".".$data->getField()); |
228 | 228 | $data->setType("custom"); |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | $data = new DateModel(); |
240 | 240 | $data = $this->setDefaultModelValue($data); |
241 | 241 | $data->setLabel($label); |
242 | - $data->setName($this->name($label,$name)); |
|
243 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
242 | + $data->setName($this->name($label, $name)); |
|
243 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
244 | 244 | $data->setOrderByColumn($this->table().".".$data->getField()); |
245 | 245 | $data->setFilterColumn($this->table().".".$data->getField()); |
246 | 246 | $data->setType("date"); |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | $data = new TimeModel(); |
258 | 258 | $data = $this->setDefaultModelValue($data); |
259 | 259 | $data->setLabel($label); |
260 | - $data->setName($this->name($label,$name)); |
|
261 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
260 | + $data->setName($this->name($label, $name)); |
|
261 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
262 | 262 | $data->setOrderByColumn($this->table().".".$data->getField()); |
263 | 263 | $data->setFilterColumn($this->table().".".$data->getField()); |
264 | 264 | $data->setType("time"); |
@@ -275,8 +275,8 @@ discard block |
||
275 | 275 | $data = new DatetimeModel(); |
276 | 276 | $data = $this->setDefaultModelValue($data); |
277 | 277 | $data->setLabel($label); |
278 | - $data->setName($this->name($label,$name)); |
|
279 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
278 | + $data->setName($this->name($label, $name)); |
|
279 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
280 | 280 | $data->setOrderByColumn($this->table().".".$data->getField()); |
281 | 281 | $data->setFilterColumn($this->table().".".$data->getField()); |
282 | 282 | $data->setType("datetime"); |
@@ -293,8 +293,8 @@ discard block |
||
293 | 293 | $data = new EmailModel(); |
294 | 294 | $data = $this->setDefaultModelValue($data); |
295 | 295 | $data->setLabel($label); |
296 | - $data->setName($this->name($label,$name)); |
|
297 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
296 | + $data->setName($this->name($label, $name)); |
|
297 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
298 | 298 | $data->setOrderByColumn($this->table().".".$data->getField()); |
299 | 299 | $data->setFilterColumn($this->table().".".$data->getField()); |
300 | 300 | $data->setType("email"); |
@@ -311,8 +311,8 @@ discard block |
||
311 | 311 | $data = new FileModel(); |
312 | 312 | $data = $this->setDefaultModelValue($data); |
313 | 313 | $data->setLabel($label); |
314 | - $data->setName($this->name($label,$name)); |
|
315 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
314 | + $data->setName($this->name($label, $name)); |
|
315 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
316 | 316 | $data->setOrderByColumn($this->table().".".$data->getField()); |
317 | 317 | $data->setFilterColumn($this->table().".".$data->getField()); |
318 | 318 | $data->setType("file"); |
@@ -330,8 +330,8 @@ discard block |
||
330 | 330 | $data = new HiddenModel(); |
331 | 331 | $data = $this->setDefaultModelValue($data); |
332 | 332 | $data->setLabel($label); |
333 | - $data->setName($this->name($label,$name)); |
|
334 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
333 | + $data->setName($this->name($label, $name)); |
|
334 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
335 | 335 | $data->setOrderByColumn($this->table().".".$data->getField()); |
336 | 336 | $data->setFilterColumn($this->table().".".$data->getField()); |
337 | 337 | $data->setType("hidden"); |
@@ -348,8 +348,8 @@ discard block |
||
348 | 348 | $data = new NumberModel(); |
349 | 349 | $data = $this->setDefaultModelValue($data); |
350 | 350 | $data->setLabel($label); |
351 | - $data->setName($this->name($label,$name)); |
|
352 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
351 | + $data->setName($this->name($label, $name)); |
|
352 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
353 | 353 | $data->setOrderByColumn($this->table().".".$data->getField()); |
354 | 354 | $data->setFilterColumn($this->table().".".$data->getField()); |
355 | 355 | $data->setType("number"); |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | $data = new MoneyModel(); |
367 | 367 | $data = $this->setDefaultModelValue($data); |
368 | 368 | $data->setLabel($label); |
369 | - $data->setName($this->name($label,$name)); |
|
370 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
369 | + $data->setName($this->name($label, $name)); |
|
370 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
371 | 371 | $data->setOrderByColumn($this->table().".".$data->getField()); |
372 | 372 | $data->setFilterColumn($this->table().".".$data->getField()); |
373 | 373 | $data->setType("money"); |
@@ -384,8 +384,8 @@ discard block |
||
384 | 384 | $data = new RadioModel(); |
385 | 385 | $data = $this->setDefaultModelValue($data); |
386 | 386 | $data->setLabel($label); |
387 | - $data->setName($this->name($label,$name)); |
|
388 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
387 | + $data->setName($this->name($label, $name)); |
|
388 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
389 | 389 | $data->setOrderByColumn($this->table().".".$data->getField()); |
390 | 390 | $data->setFilterColumn($this->table().".".$data->getField()); |
391 | 391 | $data->setType("radio"); |
@@ -402,8 +402,8 @@ discard block |
||
402 | 402 | $data = new WysiwygModel(); |
403 | 403 | $data = $this->setDefaultModelValue($data); |
404 | 404 | $data->setLabel($label); |
405 | - $data->setName($this->name($label,$name)); |
|
406 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
405 | + $data->setName($this->name($label, $name)); |
|
406 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
407 | 407 | $data->setOrderByColumn($this->table().".".$data->getField()); |
408 | 408 | $data->setFilterColumn($this->table().".".$data->getField()); |
409 | 409 | $data->setType("wysiwyg"); |
@@ -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->getFilterable()) { |
|
125 | + if ($item->getFilterable()) { |
|
126 | 126 | $newData[] = $item; |
127 | 127 | } |
128 | 128 | } |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | { |
134 | 134 | $data = $this->columns; |
135 | 135 | $newData = []; |
136 | - foreach($data as $i=>$item) { |
|
136 | + foreach ($data as $i=>$item) { |
|
137 | 137 | /** @var ColumnModel $item */ |
138 | - if($item->getShowDetail()) { |
|
138 | + if ($item->getShowDetail()) { |
|
139 | 139 | $newData[] = $item; |
140 | 140 | } |
141 | 141 | } |
@@ -145,14 +145,14 @@ discard block |
||
145 | 145 | public function getAssignmentData() |
146 | 146 | { |
147 | 147 | $data = []; |
148 | - foreach($this->columns as $column) { |
|
148 | + foreach ($this->columns as $column) { |
|
149 | 149 | /** @var ColumnModel $column */ |
150 | 150 | |
151 | - if(is_array($column->getValue())) { |
|
152 | - foreach($column->getValue() as $key=>$val) { |
|
151 | + if (is_array($column->getValue())) { |
|
152 | + foreach ($column->getValue() as $key=>$val) { |
|
153 | 153 | $data[$key] = $val; |
154 | 154 | } |
155 | - }else{ |
|
155 | + } else { |
|
156 | 156 | $data[$column->getField()] = $column->getValue(); |
157 | 157 | } |
158 | 158 | } |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | public function removeColumn($label_or_name) |
163 | 163 | { |
164 | 164 | $data = $this->getColumns(); |
165 | - foreach($data as $i=>$d) |
|
165 | + foreach ($data as $i=>$d) |
|
166 | 166 | { |
167 | 167 | /** @var ColumnModel $d */ |
168 | - if($d->getLabel() == $label_or_name || $d->getName() == $label_or_name) { |
|
168 | + if ($d->getLabel() == $label_or_name || $d->getName() == $label_or_name) { |
|
169 | 169 | unset($data[$i]); |
170 | 170 | } |
171 | 171 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | public function getColumnNameOnly() |
176 | 176 | { |
177 | 177 | $result = []; |
178 | - foreach($this->columns as $column) { |
|
178 | + foreach ($this->columns as $column) { |
|
179 | 179 | /** @var ColumnModel $column */ |
180 | 180 | $result[] = $column->getName(); |
181 | 181 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | <select v-model="item.column_type" @change="changeTypeColumn($event, idx)" class="column_type form-control"> |
224 | 224 | @foreach($types as $type) |
225 | 225 | @if($type != "." && $type != ".." && is_dir($dirPath.'/'.$type)) |
226 | - <?php $filterable = (file_exists($dirPath."/filter.blade.php"))?1:0; ?> |
|
226 | + <?php $filterable = (file_exists($dirPath."/filter.blade.php")) ? 1 : 0; ?> |
|
227 | 227 | <option data-filterable="{{ $filterable }}" value="{{ $type }}">{{ $type }}</option> |
228 | 228 | @endif |
229 | 229 | @endforeach |
@@ -797,21 +797,21 @@ discard block |
||
797 | 797 | <?php |
798 | 798 | $font = new \crocodicstudio\crudbooster\helpers\FontAwesome(); |
799 | 799 | $fontData = [ |
800 | - ["data"=>$font->text(),"label"=>"Text"], |
|
801 | - ["data"=>$font->web(),"label"=>"Web"], |
|
802 | - ["data"=>$font->video(),"label"=>"Video"], |
|
803 | - ["data"=>$font->transportation(),"label"=>"Transportation"], |
|
804 | - ["data"=>$font->payment(),"label"=>"Payment"], |
|
805 | - ["data"=>$font->medical(),"label"=>"Medical"], |
|
806 | - ["data"=>$font->hand(),"label"=>"Hand"], |
|
807 | - ["data"=>$font->fileType(),"label"=>"File Type"], |
|
808 | - ["data"=>$font->directional(),"label"=>"Directional"], |
|
809 | - ["data"=>$font->currency(),"label"=>"Currency"], |
|
810 | - ["data"=>$font->chart(),"label"=>"Chart"], |
|
811 | - ["data"=>$font->brands(),"label"=>"Brand"], |
|
812 | - ["data"=>$font->gender(),"label"=>"Gender"], |
|
813 | - ["data"=>$font->form(),"label"=>"Form"], |
|
814 | - ["data"=>$font->spinner(),"label"=>"Spinner"] |
|
800 | + ["data"=>$font->text(), "label"=>"Text"], |
|
801 | + ["data"=>$font->web(), "label"=>"Web"], |
|
802 | + ["data"=>$font->video(), "label"=>"Video"], |
|
803 | + ["data"=>$font->transportation(), "label"=>"Transportation"], |
|
804 | + ["data"=>$font->payment(), "label"=>"Payment"], |
|
805 | + ["data"=>$font->medical(), "label"=>"Medical"], |
|
806 | + ["data"=>$font->hand(), "label"=>"Hand"], |
|
807 | + ["data"=>$font->fileType(), "label"=>"File Type"], |
|
808 | + ["data"=>$font->directional(), "label"=>"Directional"], |
|
809 | + ["data"=>$font->currency(), "label"=>"Currency"], |
|
810 | + ["data"=>$font->chart(), "label"=>"Chart"], |
|
811 | + ["data"=>$font->brands(), "label"=>"Brand"], |
|
812 | + ["data"=>$font->gender(), "label"=>"Gender"], |
|
813 | + ["data"=>$font->form(), "label"=>"Form"], |
|
814 | + ["data"=>$font->spinner(), "label"=>"Spinner"] |
|
815 | 815 | ]; |
816 | 816 | ?> |
817 | 817 | @foreach($fontData as $f) |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | public function indexRender($row, $column) |
23 | 23 | { |
24 | 24 | $value = trim(strip_tags($row->{ $column->getField() })); |
25 | - if($column->getLimit()) { |
|
25 | + if ($column->getLimit()) { |
|
26 | 26 | $value = Str::limit($value, $column->getLimit()); |
27 | 27 | } |
28 | 28 | return $value; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | public function filterQuery($query, $column, $value) |
33 | 33 | { |
34 | - $query->where($column->getFilterColumn(),"like","%".$value."%"); |
|
34 | + $query->where($column->getFilterColumn(), "like", "%".$value."%"); |
|
35 | 35 | return $query; |
36 | 36 | } |
37 | 37 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | /** @var \crocodicstudio\crudbooster\types\text\TextModel $column */ |
3 | - $filterName = "filter_".slug($column->getFilterColumn(),"_"); |
|
3 | + $filterName = "filter_".slug($column->getFilterColumn(), "_"); |
|
4 | 4 | $filterValue = sanitizeXSS(request($filterName)); |
5 | 5 | ?> |
6 | 6 | <select name="filter_{{ slug($column->getFilterColumn(),"_") }}" style="width: 100%" id="filter_{{ $column->getName() }}" class="form-control select2"> |
@@ -37,15 +37,15 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | public function make() { |
40 | - $name = trim(($this->name)?:ucwords(str_replace("_"," ",$this->table))); |
|
40 | + $name = trim(($this->name) ?: ucwords(str_replace("_", " ", $this->table))); |
|
41 | 41 | |
42 | 42 | $template = file_get_contents(__DIR__."/../templates/FooBarController.stub"); |
43 | 43 | |
44 | 44 | //Replace table |
45 | - $template = str_replace("{table}",'"'.$this->table.'"', $template); |
|
45 | + $template = str_replace("{table}", '"'.$this->table.'"', $template); |
|
46 | 46 | |
47 | 47 | //Replace permalink |
48 | - $permalink = strtolower(Str::slug($name,"_")); |
|
48 | + $permalink = strtolower(Str::slug($name, "_")); |
|
49 | 49 | $template = str_replace("{permalink}", '"'.$permalink.'"', $template); |
50 | 50 | |
51 | 51 | //Replace Page title |
@@ -53,20 +53,20 @@ discard block |
||
53 | 53 | |
54 | 54 | //Replace scaffolding |
55 | 55 | $scaffold = ""; |
56 | - foreach($this->columns as $field) { |
|
56 | + foreach ($this->columns as $field) { |
|
57 | 57 | $label = $field['column_label']; |
58 | 58 | $column = $field['column_field']; |
59 | - $help = isset($field['column_help'])?"->help(\"".$field['column_help']."\")":""; |
|
60 | - $required = ($field['column_mandatory']=="on")?"":"->required(false)"; |
|
61 | - $indexShow = ($field['column_browse']=="on")?"":"->showIndex(false)"; |
|
62 | - $detailShow = ($field['column_detail']=="on")?"":"->showDetail(false)"; |
|
63 | - $editShow = ($field['column_edit']=="on")?"":"->showEdit(false)"; |
|
64 | - $addShow = ($field['column_add']=="on")?"":"->showAdd(false)"; |
|
59 | + $help = isset($field['column_help']) ? "->help(\"".$field['column_help']."\")" : ""; |
|
60 | + $required = ($field['column_mandatory'] == "on") ? "" : "->required(false)"; |
|
61 | + $indexShow = ($field['column_browse'] == "on") ? "" : "->showIndex(false)"; |
|
62 | + $detailShow = ($field['column_detail'] == "on") ? "" : "->showDetail(false)"; |
|
63 | + $editShow = ($field['column_edit'] == "on") ? "" : "->showEdit(false)"; |
|
64 | + $addShow = ($field['column_add'] == "on") ? "" : "->showAdd(false)"; |
|
65 | 65 | $optionTable = $field['column_option_table']; |
66 | 66 | $optionValue = $field['column_option_value']; |
67 | 67 | $optionDisplay = $field['column_option_display']; |
68 | 68 | $optionSqlCondition = $field['column_option_sql_condition']; |
69 | - $optionSqlCondition = str_replace('"',"'", $optionSqlCondition); |
|
69 | + $optionSqlCondition = str_replace('"', "'", $optionSqlCondition); |
|
70 | 70 | $sqlRawQuery = $field['column_sql_query']; |
71 | 71 | $options = $field['column_options']; |
72 | 72 | $imageResizeWidth = $field['column_image_width']; |
@@ -80,49 +80,49 @@ discard block |
||
80 | 80 | $moneyPrecision = $field['column_money_precision']; |
81 | 81 | $moneyThousandSeparator = $field['column_money_thousand_separator']; |
82 | 82 | $moneyDecimalSeparator = $field['column_money_decimal_separator']; |
83 | - $filterable = ($field['column_filterable']=="on")?"->filterable(true)":""; |
|
84 | - $foreign_key = (isset($field['column_foreign']))?"->foreignKey('".$field['column_foreign']."')":""; |
|
83 | + $filterable = ($field['column_filterable'] == "on") ? "->filterable(true)" : ""; |
|
84 | + $foreign_key = (isset($field['column_foreign'])) ? "->foreignKey('".$field['column_foreign']."')" : ""; |
|
85 | 85 | |
86 | 86 | // Additional Attributes |
87 | - $additional = $required . $indexShow . $detailShow . $addShow . $editShow . $help . $filterable . $foreign_key ; |
|
87 | + $additional = $required.$indexShow.$detailShow.$addShow.$editShow.$help.$filterable.$foreign_key; |
|
88 | 88 | |
89 | 89 | // Additional money |
90 | - $additional .= ($moneyPrefix && $field['column_type']=='money')?"->prefix('".$moneyPrefix."')":""; |
|
91 | - $additional .= ($moneyPrecision && $field['column_type']=='money')?"->precision('".$moneyPrecision."')":""; |
|
92 | - $additional .= ($moneyThousandSeparator && $field['column_type']=='money')?"->thousandSeparator('".$moneyThousandSeparator."')":""; |
|
93 | - $additional .= ($moneyDecimalSeparator && $field['column_type']=='money')?"->decimalSeparator('".$moneyDecimalSeparator."')":""; |
|
90 | + $additional .= ($moneyPrefix && $field['column_type'] == 'money') ? "->prefix('".$moneyPrefix."')" : ""; |
|
91 | + $additional .= ($moneyPrecision && $field['column_type'] == 'money') ? "->precision('".$moneyPrecision."')" : ""; |
|
92 | + $additional .= ($moneyThousandSeparator && $field['column_type'] == 'money') ? "->thousandSeparator('".$moneyThousandSeparator."')" : ""; |
|
93 | + $additional .= ($moneyDecimalSeparator && $field['column_type'] == 'money') ? "->decimalSeparator('".$moneyDecimalSeparator."')" : ""; |
|
94 | 94 | |
95 | 95 | // Additional for image & file type |
96 | - $additional .= ($fileEncrypt && in_array($field['column_type'],['file','image']))?"->encrypt(true)":""; |
|
97 | - $additional .= ($imageResizeWidth && in_array($field['column_type'],['file','image']))?"->resize(".$imageResizeWidth.",".$imageResizeHeight.")":""; |
|
96 | + $additional .= ($fileEncrypt && in_array($field['column_type'], ['file', 'image'])) ? "->encrypt(true)" : ""; |
|
97 | + $additional .= ($imageResizeWidth && in_array($field['column_type'], ['file', 'image'])) ? "->resize(".$imageResizeWidth.",".$imageResizeHeight.")" : ""; |
|
98 | 98 | |
99 | 99 | // Additional for date & datetime |
100 | - $additional .= ($dateFormat && in_array($field['column_type'],['date','datetime']))?"->format('".$dateFormat."')":""; |
|
100 | + $additional .= ($dateFormat && in_array($field['column_type'], ['date', 'datetime'])) ? "->format('".$dateFormat."')" : ""; |
|
101 | 101 | |
102 | 102 | // Additional for text |
103 | - $additional .= ($textDisplayLimit!="" && in_array($field['column_type'],['text','text_area','wysiwyg']))?"->strLimit(".$textDisplayLimit.")":""; |
|
104 | - $additional .= ($maxCharacter!="" && in_array($field['column_type'],['text','text_area']))?"->maxLength(".$maxCharacter.")":""; |
|
105 | - $additional .= ($minCharacter!="" && in_array($field['column_type'],['text','text_area']))?"->minLength(".$minCharacter.")":""; |
|
103 | + $additional .= ($textDisplayLimit != "" && in_array($field['column_type'], ['text', 'text_area', 'wysiwyg'])) ? "->strLimit(".$textDisplayLimit.")" : ""; |
|
104 | + $additional .= ($maxCharacter != "" && in_array($field['column_type'], ['text', 'text_area'])) ? "->maxLength(".$maxCharacter.")" : ""; |
|
105 | + $additional .= ($minCharacter != "" && in_array($field['column_type'], ['text', 'text_area'])) ? "->minLength(".$minCharacter.")" : ""; |
|
106 | 106 | |
107 | 107 | $methodName = Str::studly($field['column_type']); |
108 | - if($label && $column) { |
|
109 | - if(in_array($field['column_type'],['radio','select_option','checkbox'])) { |
|
110 | - if($options) { |
|
108 | + if ($label && $column) { |
|
109 | + if (in_array($field['column_type'], ['radio', 'select_option', 'checkbox'])) { |
|
110 | + if ($options) { |
|
111 | 111 | $optResult = []; |
112 | - foreach($options as $opt) { |
|
112 | + foreach ($options as $opt) { |
|
113 | 113 | $optResult[$opt['key']] = $opt['label']; |
114 | 114 | } |
115 | - $scaffold .= '$this->add' . $methodName . '("' . $label . '","' . $column . '")->options('.min_var_export($optResult).')' . $additional . ';' . "\n\t\t"; |
|
115 | + $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'")->options('.min_var_export($optResult).')'.$additional.';'."\n\t\t"; |
|
116 | 116 | } |
117 | - }elseif (in_array($field['column_type'],['radio_table','select_table'])) { |
|
117 | + }elseif (in_array($field['column_type'], ['radio_table', 'select_table'])) { |
|
118 | 118 | if ($optionTable && $optionValue && $optionDisplay) { |
119 | - $scaffold .= '$this->add' . $methodName . '("' . $label . '","' . $column . '",["table"=>"' . $optionTable . '","value_option"=>"' . $optionValue . '","display_option"=>"' . $optionDisplay . '","sql_condition"=>"' . $optionSqlCondition . '"])' . $additional . ';' . "\n\t\t"; |
|
119 | + $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'",["table"=>"'.$optionTable.'","value_option"=>"'.$optionValue.'","display_option"=>"'.$optionDisplay.'","sql_condition"=>"'.$optionSqlCondition.'"])'.$additional.';'."\n\t\t"; |
|
120 | 120 | } |
121 | 121 | }elseif ($field['column_type'] == "select_query") { |
122 | - if($sqlRawQuery && Str::contains($sqlRawQuery,["as `key`","as `label`"])) { |
|
123 | - $scaffold .= '$this->add' . $methodName . '("' . $label . '","' . $column . '","'.$sqlRawQuery.'")' . $additional . ';' . "\n\t\t"; |
|
122 | + if ($sqlRawQuery && Str::contains($sqlRawQuery, ["as `key`", "as `label`"])) { |
|
123 | + $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'","'.$sqlRawQuery.'")'.$additional.';'."\n\t\t"; |
|
124 | 124 | } |
125 | - }else{ |
|
125 | + } else { |
|
126 | 126 | $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'")'.$additional.';'."\n\t\t"; |
127 | 127 | } |
128 | 128 | } |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | $module['controller'] = $filename; |
146 | 146 | $module['last_column_build'] = json_encode($this->columns); |
147 | 147 | |
148 | - if($moduleData = DB::table("cb_modules")->where("name", $name)->where("table_name",$this->table)->first()) { |
|
149 | - DB::table("cb_modules")->where("id",$moduleData->id)->update($module); |
|
148 | + if ($moduleData = DB::table("cb_modules")->where("name", $name)->where("table_name", $this->table)->first()) { |
|
149 | + DB::table("cb_modules")->where("id", $moduleData->id)->update($module); |
|
150 | 150 | $id_modules = $moduleData->id; |
151 | - }else{ |
|
151 | + } else { |
|
152 | 152 | $id_modules = DB::table('cb_modules')->insertGetId($module); |
153 | 153 | } |
154 | 154 | |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | $menu['name'] = $module['name']; |
158 | 158 | $menu['type'] = 'module'; |
159 | 159 | $menu['cb_modules_id'] = $id_modules; |
160 | - if(isset($moduleData)) { |
|
161 | - DB::table("cb_menus")->where("cb_modules_id",$moduleData->id)->update($menu); |
|
162 | - }else{ |
|
160 | + if (isset($moduleData)) { |
|
161 | + DB::table("cb_menus")->where("cb_modules_id", $moduleData->id)->update($menu); |
|
162 | + } else { |
|
163 | 163 | DB::table('cb_menus')->insertGetId($menu); |
164 | 164 | } |
165 | 165 |
@@ -57,7 +57,7 @@ |
||
57 | 57 | <label>Dashboard Controller</label> |
58 | 58 | <select name="dashboard_controller" class="form-control"> |
59 | 59 | <option value="">** Default CB</option> |
60 | - <?php $controllers = glob(app_path("Http/Controllers/*Controller.php"));?> |
|
60 | + <?php $controllers = glob(app_path("Http/Controllers/*Controller.php")); ?> |
|
61 | 61 | @foreach($controllers as $controller) |
62 | 62 | @if(basename($controller) != "Controller.php") |
63 | 63 | <option {{ getSetting("dashboard_controller")==rtrim(basename($controller),".php")?"selected":"" }} value="{{ rtrim(basename($controller),".php") }}">{{ rtrim(basename($controller),".php") }}</option> |