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
News::all()->paginate(5)->sortBy('sort')
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.
1 answer
News::orderBy('sort')->paginate(5);
Find more questions by tags LaravelPHP