@@ -15,8 +15,8 @@ trait WithColumnSelect
15
15
public function mountWithColumnSelect (): void
16
16
{
17
17
// If the column select is off, make sure to clear the session
18
- if (! $ this ->columnSelect && session ()->has ($ this ->tableName . ' -columnSelectEnabled ' )) {
19
- session ()->forget ($ this ->tableName . ' -columnSelectEnabled ' );
18
+ if (! $ this ->columnSelect && session ()->has ($ this ->getColumnSelectSessionKey () )) {
19
+ session ()->forget ($ this ->getColumnSelectSessionKey () );
20
20
}
21
21
22
22
// Get a list of visible default columns that are not excluded
@@ -27,24 +27,29 @@ public function mountWithColumnSelect(): void
27
27
->toArray ();
28
28
29
29
// Set to either the default set or what is stored in the session
30
- $ this ->columnSelectEnabled = session ()->get ($ this ->tableName . ' -columnSelectEnabled ' , $ columns );
30
+ $ this ->columnSelectEnabled = session ()->get ($ this ->getColumnSelectSessionKey () , $ columns );
31
31
32
32
// Check to see if there are any excluded that are already stored in the enabled and remove them
33
33
foreach ($ this ->columns () as $ column ) {
34
34
if (! $ column ->isSelectable () && ! in_array ($ column ->column (), $ this ->columnSelectEnabled , true )) {
35
35
$ this ->columnSelectEnabled [] = $ column ->column ();
36
- session ([$ this ->tableName . ' -columnSelectEnabled ' => $ this ->columnSelectEnabled ]);
36
+ session ([$ this ->getColumnSelectSessionKey () => $ this ->columnSelectEnabled ]);
37
37
}
38
38
}
39
39
}
40
40
41
41
public function updatedColumnSelectEnabled (): void
42
42
{
43
- session ([$ this ->tableName . ' -columnSelectEnabled ' => $ this ->columnSelectEnabled ]);
43
+ session ([$ this ->getColumnSelectSessionKey () => $ this ->columnSelectEnabled ]);
44
44
}
45
45
46
46
public function isColumnSelectEnabled ($ column ): bool
47
47
{
48
48
return in_array ($ column instanceof Column ? $ column ->column () : $ column , $ this ->columnSelectEnabled , true );
49
49
}
50
+
51
+ private function getColumnSelectSessionKey (): string
52
+ {
53
+ return $ this ->tableName .'-columnSelectEnabled ' ;
54
+ }
50
55
}
0 commit comments