Mysql procedure with pagination in laravel?

Mysql procedure with pagination in laravel?

In this post we will give you information about Mysql procedure with pagination in laravel?. Hear we will give you detail about Mysql procedure with pagination in laravel?And how to use it also give you demo for it if it is necessary.

You are working on laravel with mysql database. you had created mysql procedure for get data and you want to call procedure with pagination in laravel 5 then you can not directly make pagination as laravel document.If you are using directly MySQL stored Procedure in your controller, model or repository and you want to give pagination like this way :

$data = DB::select(DB::raw('CALL hardik("hari")'))->paginate(5);

This way you found error in your Laravel 5 website. we can’t give directly this way pagination because your procedure will get all the data from database. but we can give pagination this way :

Also see:Laravel 5 – elasticsearch with pagination example

$page = Input::get('page', 1);

$paginate = 2;

$data = DB::select(DB::raw('CALL hardik("hari")'));

$offSet = ($page * $paginate) - $paginate;

$itemsForCurrentPage = array_slice($data, $offSet, $paginate, true);

$data = new IlluminatePaginationLengthAwarePaginator($itemsForCurrentPage, count($data), $paginate, $page);

return view('test',compact('data'));

Try this……..

Hope this code and post will helped you for implement Mysql procedure with pagination in laravel?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

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

  +  20  =  23

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US