I want to search for specific word instead of letter from a table. Right now i'm using like
but it not like expected:
// Category Table
-----------------------------------------------------
| id | amount | updated_at |
+----------+--------------------+-------------------+
| 1 | Bread |2016-02-10 13:17:29|
| 2 | Bread Loaf |2016-02-10 13:17:29|
| 3 | Bread1 |2016-02-10 13:17:29|
+----------+--------------------+-------------------+
For example I search for word "bread":
$words = "bread";
$query = Category::where(function ($query) use ($words) {
$query->where('name', 'like', '%' . $words . '%');
})->get();
The result: all bread is coming out.
What I expected is "Bread1" is not get query. Only Bread and Bread Loaf.
What should I add to my query?