Skip to content

Commit 3370cd6

Browse files
committed
consider blacklist in collection column search
1 parent aacd9a3 commit 3370cd6

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

src/CollectionDataTable.php

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,35 +93,38 @@ public function columnSearch()
9393
{
9494
$columns = $this->request->get('columns', []);
9595
for ($i = 0, $c = count($columns); $i < $c; $i++) {
96-
if ($this->request->isColumnSearchable($i)) {
97-
$this->isFilterApplied = true;
96+
$column = $this->getColumnName($i);
9897

99-
$regex = $this->request->isRegex($i);
100-
$column = $this->getColumnName($i);
101-
$keyword = $this->request->columnKeyword($i);
98+
if (! $this->request->isColumnSearchable($i) || $this->isBlacklisted($column)) {
99+
continue;
100+
}
102101

103-
$this->collection = $this->collection->filter(
104-
function ($row) use ($column, $keyword, $regex) {
105-
$data = $this->serialize($row);
102+
$this->isFilterApplied = true;
106103

107-
$value = Arr::get($data, $column);
104+
$regex = $this->request->isRegex($i);
105+
$keyword = $this->request->columnKeyword($i);
108106

109-
if ($this->config->isCaseInsensitive()) {
110-
if ($regex) {
111-
return preg_match('/' . $keyword . '/i', $value) == 1;
112-
}
107+
$this->collection = $this->collection->filter(
108+
function ($row) use ($column, $keyword, $regex) {
109+
$data = $this->serialize($row);
113110

114-
return strpos(Str::lower($value), Str::lower($keyword)) !== false;
115-
}
111+
$value = Arr::get($data, $column);
116112

113+
if ($this->config->isCaseInsensitive()) {
117114
if ($regex) {
118-
return preg_match('/' . $keyword . '/', $value) == 1;
115+
return preg_match('/' . $keyword . '/i', $value) == 1;
119116
}
120117

121-
return strpos($value, $keyword) !== false;
118+
return strpos(Str::lower($value), Str::lower($keyword)) !== false;
122119
}
123-
);
124-
}
120+
121+
if ($regex) {
122+
return preg_match('/' . $keyword . '/', $value) == 1;
123+
}
124+
125+
return strpos($value, $keyword) !== false;
126+
}
127+
);
125128
}
126129
}
127130

0 commit comments

Comments
 (0)