Custom Pagination View in Laravel 5

Custom pagination view in Laravel 5

Whereas in Laravel 4.2 I would use:

{{ $users->links('view.name') }}

In Laravel 5 you can replicate the above with the following:

@include('view.name', ['object' => $users])

Now in the included view, $object will have the pagination methods available, such as currentPage(), lastPage(), perPage(), etc.

You can view all methods available at http://laravel.com/docs/5.0/pagination

Laravel: customize page links in pagination

You have to launch this command from terminal:

php artisan vendor:publish --tag=laravel-pagination

This creates the views in the resources/views/vendor/pagination directory.

Now you can apply your classes in the view: default.blade.php.

Read the documentation here: https://laravel.com/docs/5.6/pagination#customizing-the-pagination-view

Custom pagination view in Laravel 5 with appended link

Durp.

@include('pagination.default', ['paginator' => $users->appends(['sortBy' => $sort, 'order' => $order])])



Related Topics



Leave a reply



Submit