vendredi 17 novembre 2017

How to paginate in eager loading?

I have posts and comments tables. Post and Comment have one-to-many relationship.

$posts = Post::with(array('comments' => function($c) {
          $c->paginate(5);
     }, 'comments.user'))->paginate(10);

But I can't evaluate the links for comments with the following code:

$post->comments->links();

This gives the following error: Call to undefined method Illuminate\Database\Eloquent\Collection::links

How can I evaluate comment links?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2A7KOLK
via IFTTT

Aucun commentaire:

Enregistrer un commentaire