title: get Post fields and for each Post: details of last Comment
body: <p>Using Laravel (v6), would like to get collection of matching Posts with <em>last</em> Comment.<br>
  Or, in my situation: matching Places, with details of <em>last</em> visit.</p>
  
  <pre><code>class Place extends Model
  {
      public function visits(){
          return $this-&gt;hasMany(Timeline::class);
      }
  
      public function lastVisit(){
          return $this-&gt;visits()-&gt;orderBy('end', 'desc')-&gt;limit(1);
      }
  ...
  </code></pre>
  
  <p>This works fine for a single Place:</p>
  
  <pre><code>Place::where('id',2)-&gt;withCount('visits')-&gt;with('lastVisit')-&gt;get()
  </code></pre>
  
  <p>but for multiple Places it only shows the lastVisit for the <strong>last</strong> Place:</p>
  
  <pre><code>Place::where('name','like','%hotel%')-&gt;withCount('visits')-&gt;with('lastVisit')-&gt;get()
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code>Place::where('name','like','%hotel%')
  -&gt;withCount('visits')
  -&gt;with(['visits' =&gt; function($e) {return $e-&gt;orderBy('end','desc')-&gt;first(); }])
  -&gt;get()
  </code></pre>
  
  <p>This shows only the last Visit for the last Place, so: only one Visit in total.</p>
  
  <p>When I leave out <code>-&gt;first()</code> each Place does include <strong>all</strong> Visits to that Place (sorted by last visit)</p>
  
  <pre><code>Place::where('name','like','%hotel%')
  -&gt;withCount('visits')
  -&gt;with(['visits' =&gt; function($e) {return $e-&gt;orderBy('end','desc'); }])
  -&gt;get()
  </code></pre>
  
  <p>How do I get just the last Visit for each Place?</p>