Skip to content

Commit 2701203

Browse files
authored
Merge pull request #432 from amvisor/view_columns
move view columns array to class property
2 parents 0b1068c + 8571d87 commit 2701203

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

src/Http/Livewire/LivewireDatatable.php

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,31 @@ class LivewireDatatable extends Component
115115
'does not include' => '<>',
116116
];
117117

118+
protected $viewColumns = [
119+
'index',
120+
'hidden',
121+
'label',
122+
'tooltip',
123+
'group',
124+
'summary',
125+
'content',
126+
'headerAlign',
127+
'contentAlign',
128+
'type',
129+
'filterable',
130+
'hideable',
131+
'sortable',
132+
'complex',
133+
'filterView',
134+
'name',
135+
'params',
136+
'wrappable',
137+
'width',
138+
'minWidth',
139+
'maxWidth',
140+
'preventExport',
141+
];
142+
118143
/**
119144
* This events allows to control the options of the datatable from foreign livewire components
120145
* by using $emit.
@@ -273,30 +298,9 @@ public function columns()
273298
public function getViewColumns()
274299
{
275300
return collect($this->freshColumns)->map(function ($column) {
276-
return collect($column)->only([
277-
'index',
278-
'hidden',
279-
'label',
280-
'tooltip',
281-
'group',
282-
'summary',
283-
'content',
284-
'headerAlign',
285-
'contentAlign',
286-
'type',
287-
'filterable',
288-
'hideable',
289-
'sortable',
290-
'complex',
291-
'filterView',
292-
'name',
293-
'params',
294-
'wrappable',
295-
'width',
296-
'minWidth',
297-
'maxWidth',
298-
'preventExport',
299-
])->toArray();
301+
return collect($column)
302+
->only($this->viewColumns)
303+
->toArray();
300304
})->toArray();
301305
}
302306

0 commit comments

Comments
 (0)