How to add pagination in Laravel example


0

In this tutorial we will learn how to add pagination in laravel

There are several ways to paginate in laravel. The simpler way to make pagination item in laravel is paginate method on the query builder or an Significant query.

It’s automatically add the pagination to item, table etc.

In this laravel code we pass argument 10 to show 10 item per page.

UserController.php

<?php
<?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_data')->paginate(10);
		return view('user.index', ['users_data' => $users]);
    }
}

Also Read: How to integrate OTP in LARAVEL


Like it? Share with your friends!

0
Developer

0 Comments