@evanzyl instead of using ->get() use ->paginate(20) or the number or rows per page as the argument. in your blade, use $bookings->links() if that don't work, use $bookings->render(). can't remember which works in the older versions of laravel. that will display the page number links. then the loop that displays the records should have a limit per page based on the value passed in paginate().
Jan 19, 2017
2
Level 1
Pagination in laravel
Good day
Is there anybody that can help me with adding pagination to laravel 5?
I inherited a site and not sure how to add it.
This is the function:
Route::get('/bookings', array( 'as' => 'private-bookings', function () {
//show the page:
$viewData = array(
'metaTitle' => 'Bookings | ' . config('app.name'),
'metaSectionJs' => 'private-bookings',
'metaSectionParent' => 'private-bookings',
'metaSectionUrl' => '/bookings/',
'bookings' => \Customerbooking\Booking::whereNull('deleted_at')
->whereIn('status', array('draft', 'booked', 'paid', 'cancelled'))
->orderBy('created_at', 'desc')
->get()
);
return view('private.bookings.index', $viewData);
}
));
Do I add it here or on the blade?
Any assistance would be greatly appreciated.
Thank you.
Please or to participate in this conversation.