Skip to content

Problem with where clause with LIKE in it #35

@rodinmehr

Description

@rodinmehr

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions