How to use paging with Laravel DB::select?

Asked

Viewed 2,148 times

1

testeController.php

$jogos = DB::select("select * from jogo where id_u ='$id_u'");

This is the code I wish to page in View using blade

game.blade.php

{!! $jogos->links() !!}

$jogos = DB::select("select * from jogo where id_u ='$id_u' ")->paginate(2);

I’ve tried, but it doesn’t work.

1 answer

3


When using the DB::select your return is a array of stdClass without paging, is the way to do in the simple way and without great resources, that is, it does not have the methods of Query Builder you need to generate a pagination of results. The simplest way to generate a pagination on :

\DB::table('jogo')->where('id_u',$id_u)->paginate();

now with that Query Builder will be generated the pagination to which you need, ie the only way to make a pagination of results in the according to your documentation is with Query Builder.

References:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.