I'm currently trying to implement a search for keywords/tags in my db.
In my db, I have lines with keywords like:
auto,cabrio,frischluft
or
hose,jeans,blaue hose,kleidung
so always some keywords (that can basically also have a whitespace), seperated by a comma (,
).
Now I want to be able to find a product in my db that has some keywords entered.
With LIKE
I can find the two entries I mentioned with queries like auto,cabrio
or also cabrio,frischluft
or hose,jeans,blau
or hose,kleidung
. But what happens if I enter auto,frischluft
or something like hose,blaue hose
or jeans,kleidung
?
Then LIKE
wont work any more. Is there a way to do this?
I hope you know what I mean...
So just to make it clear: The code I currently use is:
$searchQuery = "%".$request->input('productSearch')."%";
and $products = Product::where('name', 'LIKE', $searchQuery)->paginate(15);
But as I said, this won't bring me back the article with the keyowrds auto,cabrio,frischluft
if the input productSearch
has the keywords auto,frischluft
entered...
Any ideas?