Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CollectionDataTable, globalSearch(), non string values are not searchable #2992

Open
dfischer-de opened this issue Apr 27, 2023 · 2 comments

Comments

@dfischer-de
Copy link

Summary of problem or feature request

Non-string values are not searchable for laravel collections in global search.

Code snippet of problem

.../vendor/yajra/laravel-datatables-oracle/src/CollectionDataTable.php

protected function globalSearch(string $keyword): void
...
            foreach ($this->request->searchableColumnIndex() as $index) {
                $column = $this->getColumnName($index);
                $value = Arr::get($data, $column);
                if (! is_string($value)) {
                    continue;
                } else {
                    $value = $this->config->isCaseInsensitive() ? Str::lower($value) : $value;
                }
...
    }

Due to "continue", we leave the foreach loop and it does all non string values non searchable.
My solution:

if (is_string($value)) {
  $value = $this->config->isCaseInsensitive() ? Str::lower($value) : $value;
}

Please help me to unterstand, is this a bug or are non string values not supposed to be searchable?
Thank you!

System details

  • Operating System Ubuntu 20.04.5 LTS
  • PHP v8.2.3
  • Laravel v10.9.0
  • Laravel-Datatables v10.4.0
@github-actions
Copy link

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the stale label May 28, 2023
@dfischer-de
Copy link
Author

up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants