You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.
I currently use global search in almost all my tables. I was looking for a way to improve the example documentation and would like to collaborate with other users on a possible cleaner option.
Currently according to the documentation you can do this:
$globalSearch = AllowedFilter::callback('global', function ($query, $value) {
$query->where(function ($query) use ($value) {
Collection::wrap($value)->each(function ($value) use ($query) {
$query
->orWhere('name', 'LIKE', "%{$value}%")
->orWhere('email', 'LIKE', "%{$value}%");
});
});
});
I am not a query builder expert so the filter could very possibly be optimised. Any suggestions would be appreciated.
I just wanted to share this idea with other users to improve the implementation of this table feature. Maybe we could get an almost perfect global filter class that could be included in the package itself.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hello,
I currently use global search in almost all my tables. I was looking for a way to improve the example documentation and would like to collaborate with other users on a possible cleaner option.
Currently according to the documentation you can do this:
And use like:
This works fine, but does not allow you to search through relationships globally in a simple and clean way.
Instead of the above, you can create a custom filter class like this:
Then you can search through model columns and relationships with a few lines of code keeping your controller more cleaner:
I am not a query builder expert so the filter could very possibly be optimised. Any suggestions would be appreciated.
I just wanted to share this idea with other users to improve the implementation of this table feature. Maybe we could get an almost perfect global filter class that could be included in the package itself.
The text was updated successfully, but these errors were encountered: