Laravel - Pagination Settings

Laravel includes a pagination feature which helps the user or developer to enable the pagination feature. Lagvel paginator is integrated with query builder and Eloquent ORM. The paginate method will automatically take care of setting the required limit and the given offset. It takes only one parameter for pagination, which is the number of items to display on one page.
Laravel 5.7 includes a new pagination method for setting the number of pages on each side of the paginator. The new method no longer needs a custom pagination view.
The code demonstration of custom pagination view is given below −
<?php namespace App\Http\Controllers; use Illuminate\Support\Facades\DB; use App\Http\Controllers\Controller; class UserController extends Controller{ /** * Show all of the users for the application. * * @return Response */ public function index() { $users = DB::table('users')->paginate(15); return view('user.index', ['users' => $users]); } }
The new pagination setup according to Laravel standards is mentioned below −
<?php User::paginate(10)->onEachSide(5);
Note that onEachSide refers to a subsection of each pagination entry with 10 and subsection 5.