该表在没有该paginate(5)
功能的情况下加载良好,但是当我添加分页功能时,它显示错误。
public function index(Request $request)
{
$userid = $request->user()->assets()->get(['id']);
$arr['love'] = Love::find($userid)->paginate(5);
return view('admin.love.index')->with($arr);
}
错误:
Whoops, looks like something went wrong.
(1/1) BadMethodCallException
Method paginate does not exist.
in Macroable.php line 74
at Collection->__call('paginate', array(5))in AssetsController.php line 26
答案通过使用 whereIn 而不是 where 解决。
public function index(Request $request)
{
$userid = $request->user()->assets()->get(['id']);
$arr['love'] = Love::whereIn('user_id', $userid)->paginate(5);
return view('admin.love.index')->with($arr);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句