Filter Eloquent results Laravel 5.2
<p>I want to make a member search with some filter options.</p>

<p>I tried <strong>filter()</strong>, but I got this error:</p>

<pre><code>Fatal error: Call to a member function filter() on array
</code></pre>

<p>It works when I use only one filter, because it only returns the id's.
Is their a way I can use filter() multiple times, this is my code:</p>

<pre><code>$members = User::all();

if ($has_avatar) {
    $members = $members-&gt;filter(function ($member) {
        //Avatar is not empty, other wise false
        return ($member-&gt;avatar != "") ? true : false;
    });
}
if ($is_online) {
    $members = $members-&gt;filter(function ($member) {
        //User is now online, other wise false
        return ($member-&gt;is_online == 1) ? true : false;
    });
}
</code></pre>

<p>Or is there a other way to achieve this?</p>