Skip to content

Commit

Permalink
Merge pull request #432 from amvisor/view_columns
Browse files Browse the repository at this point in the history
move view columns array to class property
  • Loading branch information
thyseus authored Mar 28, 2022
2 parents 0b1068c + 8571d87 commit 2701203
Showing 1 changed file with 28 additions and 24 deletions.
52 changes: 28 additions & 24 deletions src/Http/Livewire/LivewireDatatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,31 @@ class LivewireDatatable extends Component
'does not include' => '<>',
];

protected $viewColumns = [
'index',
'hidden',
'label',
'tooltip',
'group',
'summary',
'content',
'headerAlign',
'contentAlign',
'type',
'filterable',
'hideable',
'sortable',
'complex',
'filterView',
'name',
'params',
'wrappable',
'width',
'minWidth',
'maxWidth',
'preventExport',
];

/**
* This events allows to control the options of the datatable from foreign livewire components
* by using $emit.
Expand Down Expand Up @@ -273,30 +298,9 @@ public function columns()
public function getViewColumns()
{
return collect($this->freshColumns)->map(function ($column) {
return collect($column)->only([
'index',
'hidden',
'label',
'tooltip',
'group',
'summary',
'content',
'headerAlign',
'contentAlign',
'type',
'filterable',
'hideable',
'sortable',
'complex',
'filterView',
'name',
'params',
'wrappable',
'width',
'minWidth',
'maxWidth',
'preventExport',
])->toArray();
return collect($column)
->only($this->viewColumns)
->toArray();
})->toArray();
}

Expand Down

0 comments on commit 2701203

Please sign in to comment.