Reputation: 484
I am quite new to Laravel and started to play around with L5 and tried to paginate my data (from my HomeController method):
someMethod(){
...
$messages = Message::paginate(50)->sortByDesc('timestamp');
return view('home', ['messages' => $messages]);
}
in my home.blade view:
...
<div class="list-group">
@foreach($messages as $message)
@if(!$message->processed)
...
@endif
@endforeach
</div>
{!! $messages->render() !!}
...
I get the error below:
FatalErrorException in b706d42af4b0adc08aee8abb2fdf4ba9 line 105:
Call to undefined method Illuminate\Database\Eloquent\Collection::render()
in b706d42af4b0adc08aee8abb2fdf4ba9 line 105
I followed the logic from the Pagination doc page : https://laravel.com/docs/5.1/pagination#basic-usage and https://laravel.com/docs/5.1/pagination#displaying-results-in-a-view
Upvotes: 2
Views: 1723
Reputation: 163748
You have an error in your code. Try this:
$messages = Message::orderBy('timestamp', 'desc')->paginate(50);
Upvotes: 3