Proposal for Native whereLike
Method in Laravel Query Builder
#51756
rupeshstha
started this conversation in
Polls
Replies: 2 comments 3 replies
-
Bear in mind that any or or like %ddd% in your query messes up the index query and slows down the query. Full text search index was invented just for what you want. Eloquent does not support it so you must raw code it. I would not put this code in laravel as it is generating a slow db query execution for sure. |
Beta Was this translation helpful? Give feedback.
3 replies
-
I'd just extract this in a scope to be honest, we already can use `->where($column, 'like', "%$value%")', if you want to scope this to multiple columns as once making a reusable scope is the play here. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have been working on a feature where I need a whereLike method to perform case-insensitive searches across multiple attributes. Currently, I am using a macro to extend the query builder with this functionality. Here is my implementation:
Proposal
I believe that having a native whereLike method in Laravel's query builder would be beneficial for many developers, as it simplifies the process of performing case-insensitive searches and supports searching through related models.
Benefits
Usage Example
Here’s how the whereLike method can be used with the current macro:
7 votes ·
Beta Was this translation helpful? Give feedback.
All reactions