Pagination Query use in Laravel

Paginate Query Builder in Laravel, simplePaginate Query Builder in Laravel 5.8, Paginate Query in Laravel 5.8, Paginate Query in Laravel 5.7, Paginate Query in Laravel 5.6, Paginate Query in Laravel 5.5, Paginate Query in Laravel 5.4, Paginate Query in Laravel 5.3, Paginate Query in Laravel 5.2

Hi guys, today we will tell you through this tutorial that why and why do we use paginate query in laravel.

When you are working on an article or blog and you post 25 or more articles and all the articles show on your same page. If you want this article to be no more than 10, then use paginate query to show 10 work articles in laravel

So let’s understand how to use paginate query in laravel.

In laravel you can create paginate query by query builder in this way. You can implement in your project by looking at and understanding below.

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use DB;
use Redirect;

class ArticleController extends Controller
{
public function article()
{
$list = DB::table('article')->paginate(15);
return view('article')->with('list', $list);
}
}
?>

Then you can get the data of foreach loop chaala in your article list (blade file) page, which is explained below in the example.

<div class="container">
<?php foreach ($list as $lists): ?>
<?php echo $lists->title; ?>
<?php endforeach; ?>
</div>
<?php echo $list->render(); ?>