Collection Where LIKE Laravel 5.4 : <p>I know collection doesn't support where LIKE but how can I achieve this.</p>

<p>My data is:
<a href="https://i.stack.imgur.com/A7ldY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/A7ldY.png" alt="enter image description here"></a></p>

<pre><code>collect($products)-&gt;where('name', 'LIKE', '%'. $productName . '%');
</code></pre>

<p>Laravel doesn't support where like in the collection. I'm thinking to use </p>

<pre><code>collect($products)-&gt;filter( function () use ($productName) {

            return preg_match(pattern, subject);
        })
</code></pre>

<p>but I don't know how to do it. TY</p>
