我想对我的联接查询进行分页。它显示:方法分页不存在。
我已经在控制器中编写了查询
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'));
}
错误:
方法分页不存在。 如何解决错误并进行分页
答案 0 :(得分:5)
您正尝试在集合上调用paginate
,paginate
是“查询”构建器上的一种方法,请尝试以下操作:
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'));
}
注意,get()
方法已删除。