Skip to main content

Pagination in laravel

  • Use paginate method in controller and call links() method in view file to display pagination links

    app\Http\Controllers\<HomeController>.php

    //paginate method to display 10 records per page
    $users = DB::table('users')->paginate(10);

    resources\views\<home>.blade.php

    //view file code to display pagination
    {{ $users->links() }}

    You can use paginate method by passing the number of records you want to display per page and you can call the links() methon in view file to display the pagination links.

  • Back to code snippet queries related laravel

Related queries helps you to understand and may also used for implementation of current code snippet