CodeIgniter Laravel PHP Example Javascript jQuery MORE
Need a Website Or Web Application Or Any Help.Contact Us: +91 9437911966 (Whatsapp) Note: Paid Service

Laravel pagination example


There are various ways to paginate in laravel. The eaisest way is paginate item in laravel is paginate method on the query builder or an Eloquent query.

It's automatically add the paginate to item, table etc.

In this example 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]);
    }
}