jeudi 25 janvier 2018

Paginate in relationship and order by

I have List. List has many posts.

I want to get all post of some lists, sort posts and paginate it.

I try this:

$list = List::whereId('1')->firstOrFail();
$posts = $feed->posts()->orderBy('id')->paginate(Request::input('per_page'))->appends(Request::input());

return compact('list','posts');

Now I can get List and paginate posts, but ordeBy doesn't work? How order it? Or any other way to solve this problem?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire