Laravel - Query Model if values contain a certain string (taken from search input)
<p>I am implementing a search using Laravel and Ajax. So I have a Product which belongs to a Tag and a Subcategory. On the other hand the Subcategory belongs to a Category. I want to check all of their properties (field values) and check if they contain the given string. With some searching I found out that I have to use <code>LIKE</code>.  Here is what I tried:</p>

<pre><code>$products = Product::where('name_en', 'LIKE', $search)-&gt;get();
</code></pre>

<p>However this will get the products if the search string matches exactly the value. I want to match if it contains it. How can I proceed with the belongsTo relationships? How can I check the propreties of Tag and Subcategory as well? How to chain everything together so I achieve the desired result? Thanks in advance.</p>