Why not working on laravel paginate() method with the sortBy?

Trying to do pagination in laravel, but that's what happened plugging.
If the output of the news list on 5 pieces, then do so
$news = News::paginate(5);
and everything works fine. Links to pages output using {!! $news->render() !!}

But I need the records removed from the database sorted by a specific field.
Without pagination I did so
$news = News::all()->sortBy('sort');
But if you add a method paginate() ie
$news = News::all()->sortBy('sort')->paginate(5)
it complains that the method paginate() not found.

I tried to do so
in this case the sampling has occurred, the records displayed on the screen, but does not display links to pages, ie does not work {!! $news->render() !!} (write the render() method not found).
His head broke do not understand how to show records with pagination while using sort.
July 9th 19 at 13:26
1 answer
July 9th 19 at 13:28
Works, thank you! Damn, how did I ever get this method sortBy()? From the old version of Caravela chtoli... )) - Liam.Mosciski commented on July 9th 19 at 13:31
sortBy is invoked on the existing collection. And orderBy is a method of the query Builder. - jules_Nolan10 commented on July 9th 19 at 13:34

Find more questions by tags LaravelPHP