Home > Back-end >  Laravel Paginate not working with specific model or table
Laravel Paginate not working with specific model or table

Time:05-11

Paginate not working for specific model. with all Models, paginate is working fine except one specific model. Also tried with query builder.

$doubts = DB::table('users')->paginate(10);
  dd($doubts->count());

//output: 10

$doubts = DB::table('doubts')->paginate();
  dd($doubts->count());

//output: 0

$doubts = DB::table('doubts')->get();
  dd($doubts->count());

//output: 8

Don't know what am I missing here. Please help.

CodePudding user response:

Maybe I think you have to put How many results you want to show per page So if you want 8 Then I think it should be something like this

$doubts = DB::table('doubts')->paginate(8); dd($doubts->count());

And if you are using pages Number under your data then you might need the query builder.

CodePudding user response:

You should pass number argument inside paginate function. Look at laravel pagination documentation

And make sure that DB::table('doubts') Is returning collection

  • Related