How to use pagination with Laravel DB :: select?

1
  

testController.php

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

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

  

jogo.blade.php

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

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

I've tried, but it does not work.

    
asked by anonymous 27.09.2017 / 01:42

1 answer

3

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

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

Now with this Query Builder you will be generating the page you need, that is, the only way to make a pagination of results on the according to your documentation is Query Builder .

References:

27.09.2017 / 01:57