title: Laravel with() and search using LIKE not working
body: <p>So I have 2 tables, 1 table for storing debt(id, amount, category_id) and 1 table for storing debt categories(id, name). I am trying to pull the data for each month from the debt table, but I also have a search which seems to not work, I guess I am missing something.</p>
  <p>I have the following:</p>
  <pre><code>    $debt = $this-&gt;debtModel
          -&gt;select(DB::raw('MONTH(created_at) as month'), DB::raw('SUM(amount) as amount'), 'category_id')
          -&gt;where('user_id', Auth::user()-&gt;id)
          -&gt;whereYear('created_at', $year)
          -&gt;with(['category' =&gt; function ($query) use ($filter) {
              $query-&gt;where('name', 'like', &quot;%$filter%&quot;);
          }])
          -&gt;orderBy('month', 'asc')
          -&gt;groupBy('month')
          -&gt;groupBy('category_id')
          -&gt;get();
  </code></pre>
  <p>Debt Model:</p>
  <pre><code>public function category()
  {
      return $this-&gt;hasOne('App\Models\DebtCategory', 'id', 'category_id');
  }
  </code></pre>
  <p>This works fine, with the exception of search, If I try to filter by a category name it still returns everything.</p>