简体   繁体   中英

Laravel 5: Pagination links on raw query does not work

I have a raw query which is working properly but i am trying to paginate it as below

$query_result = DB::select($query);
$query_result = new Paginator($query_result, 5, 1);
return view('pages.printout', compact('query_result'));

And in blade

{!! str_replace('/?', '?', $query_result->render()) !!}

First page comes up okay, it paginates first 5 records but when i click to pagination links no change happens. Any help would be appreciated.

You can do in this way

$query_result = DB::select($query)->paginate(5);
return view('pages.printout', compact('query_result'));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM