title: Can you paginate a nested query with Laravel?
body: <p>Is it possible to paginate this nested query?</p>
  
  <p><strong>User.php</strong></p>
  
  <pre><code>public function favoritePosts()
  {
      return $this-&gt;morphedByMany('App\Post', 'favoritable', 'favorites')
                  -&gt;withTimestamps();
  }
  </code></pre>
  
  <p><strong>ProfilesController.php</strong></p>
  
  <pre><code>public function posts($username)
  {
      $user = User::with(['profile', 'favoritePosts' =&gt; function($q){
          $q-&gt;paginate(15);
      }])-&gt;whereUsername($username)-&gt;firstOrFail();
      return view('profiles.posts')-&gt;withUser($user);
  }
  </code></pre>
  
  <p><strong>profiles/posts.blade.php</strong></p>
  
  <pre><code>...
  {!! $user-&gt;favoritePosts-&gt;appends(Request::except('page'))-&gt;render() !!}
  ...
  </code></pre>
  
  <p><strong>error</strong></p>
  
  <p><code>Call to undefined method Illuminate\Database\Eloquent\Collection::appends()</code></p>