diff --git a/src/QueryBuilder.php b/src/QueryBuilder.php index b4c1226..8862f0c 100644 --- a/src/QueryBuilder.php +++ b/src/QueryBuilder.php @@ -218,16 +218,16 @@ protected function filter(Query $query): string */ protected function filterGlobal(Query $query): string { - $searchinput = preg_replace("/\W+/u", ' ', $this->options->searchValue()); + $searchInput = preg_replace("/\W+/u", ' ', $this->options->searchValue()); $columns = $this->columns->searchable(); - if ($searchinput === null || $searchinput === '' || \count($columns) === 0) { + if ($searchInput === null || $searchInput === '' || \count($columns) === 0) { return ''; } $search = []; - foreach (explode(' ', $searchinput) as $word) { + foreach (explode(' ', $searchInput) as $word) { $look = []; foreach ($columns as $column) { @@ -253,6 +253,8 @@ protected function filterIndividual(Query $query): string $look[] = $this->columnFilter($column, new FilterHelper($query, $column, $this->db)); } + $look = array_filter($look); + return implode(' AND ', $look); } @@ -325,4 +327,4 @@ public function columnFilter(Column $column, FilterHelper $helper): string return $helper->defaultFilter(); } -} \ No newline at end of file +}