Reputation: 2637
I want to paginate my join query. It displays: Method paginate does not exist.
I have written the query in controller
public function userBilling()
{
$billings = DB::table("billings")
->select("billings.email", "billings.plan","users.name","users.username", DB::raw("SUM(played_game.amount) as total"))
->join("users","users.email","=","billings.email")
->groupBy("users.email","users.name","users.username","billings.plan")
->orderByRaw('billings.email DESC')
->get()
->paginate(15);
return view('report.userBilling', compact('billings'));
}
Error:
Method paginate does not exist. How do I resolve the error and do my pagination
Upvotes: 1
Views: 136
Reputation: 14268
You are trying to call paginate
on a collection, paginate
is a method on the Query builder so try this instead:
public function userBilling()
{
$billings = DB::table("billings")
->select("billings.email", "billings.plan","users.name","users.username", DB::raw("SUM(played_game.amount) as total"))
->join("users","users.email","=","billings.email")
->groupBy("users.email","users.name","users.username","billings.plan")
->orderByRaw('billings.email DESC')
->paginate(15);
return view('report.userBilling', compact('billings'));
}
notice the get()
method is removed.
Upvotes: 5