Skip to content

Commit 7889153

Browse files
committed
refactor to remove extra property
1 parent df40939 commit 7889153

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/DataTableComponent.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public function boot(): void
6666
$this->{$this->tableName} = [
6767
'sorts' => $this->{$this->tableName}['sorts'] ?? [],
6868
'filters' => $this->{$this->tableName}['filters'] ?? [],
69+
'columns' => $this->{$this->tableName}['columns'] ?? [],
6970
];
7071

7172
// Set the filter defaults based on the filter type

src/Traits/ComponentUtilities.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ trait ComponentUtilities
1414

1515
public array $table = [];
1616
public $theme = null;
17-
public array $userSelectedColumns = [];
1817
protected Builder $builder;
1918
protected $model;
2019
protected $primaryKey;
@@ -58,7 +57,6 @@ public function queryString(): array
5857
if ($this->queryStringIsEnabled()) {
5958
return [
6059
$this->getTableName() => ['except' => null, 'as' => $this->dataTableFingerprint()],
61-
'userSelectedColumns' => ['except' => null, 'as' => $this->dataTableFingerprint() . '-c'],
6260
];
6361
}
6462

src/Traits/WithColumnSelect.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public function setupColumnSelect(): void
3636
->toArray();
3737

3838
// Set to either the default set or what is stored in the session
39-
$this->selectedColumns = count($this->userSelectedColumns) > 0 ?
40-
$this->userSelectedColumns :
39+
$this->selectedColumns = (isset($this->{$this->tableName}['columns']) && count($this->{$this->tableName}['columns']) > 0) ?
40+
$this->{$this->tableName}['columns'] :
4141
session()->get($this->getColumnSelectSessionKey(), $columns);
4242

4343
// Check to see if there are any excluded that are already stored in the enabled and remove them
@@ -51,7 +51,7 @@ public function setupColumnSelect(): void
5151

5252
public function updatedSelectedColumns(): void
5353
{
54-
$this->userSelectedColumns = $this->selectedColumns;
55-
session([$this->getColumnSelectSessionKey() => $this->userSelectedColumns]);
54+
$this->{$this->tableName}['columns'] = $this->selectedColumns;
55+
session([$this->getColumnSelectSessionKey() => $this->{$this->tableName}['columns']]);
5656
}
5757
}

0 commit comments

Comments
 (0)