Laravel 7.2 routing with route group auth guard check with prefixLaravel 7.2 routing with route group auth guard check with prefix

Hello to all, welcome to therichpost.com. In this post, i will tell you, Laravel pagination using mysql limit offset.

Laravel is the top mvc framework in php.

Here is working and tested code for Laravel pagination using mysql limit offset:
// Paginate
$limit = 2;

//$_GET['page'] - get page number form url like - www.therichpost.com?page=1

$offset = (null !== $_GET['page']) ? ($_GET['page'] == 1) ? 0 : ($_GET['page']-1) * $limit : 0;

$raw_sql = 'SELECT * FROM user';

//get total number of pages divided by limit
$total_pages = sizeof(DB::select(DB::raw($raw_sql))) / $limit;

$query = 'SELECT * FROM user LIMIT '.$limit.' OFFSET '.$offset;

$user = DB::select(DB::raw($query));

 

 If you have any query related to this post, then feel free to ask. the rich post

 

By therichpost

Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 19, MedusaJs, Next.js, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.