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

Problem with where clause with LIKE in it #35

Open
rodinmehr opened this issue Jul 3, 2022 · 0 comments
Open

Problem with where clause with LIKE in it #35

rodinmehr opened this issue Jul 3, 2022 · 0 comments

Comments

@rodinmehr
Copy link

rodinmehr commented Jul 3, 2022

I'm using NestableTrait in my model. I want to use where to select some of the rows. My model is Category
Category::where('name', "Clothes"); works fine. But if I want to use it like this:
Category::where('name', 'LIKE', "%Clothes%"); it doesn't have any items in it.
When I use a raw query to get the columns it has some items in it:
collect(DB::select("SELECT * FROM categoriesWHEREname LIKE '%clothes%';"));

Any idea how I can fix this? I would have used the raw query but I want the model's relations as well, and it doesn't make any sense to add the relations by join when I can simply use the model.

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

No branches or pull requests

1 participant