From b0a3369f5d3e002e3681734283fb2da170600b76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20=C3=96zdemir?= Date: Sat, 8 Jun 2024 00:28:28 +0300 Subject: [PATCH] Update QueryBuilder.php --- src/QueryBuilder.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 +}