Paul_nld's avatar

Paginate gives error

I have a list that I want to display with pagination, when I use the script below I get the error that links do not exist. Without the where conditions it works what am I doing wrong

$adresses = Adresses::paginate(10) ->where('active', 1) ->where('user_id',Auth::user()->id); return view('adresses.home', compact('adresses'));

0 likes
3 replies
Nakov's avatar

Have you tried putting paginate at the end:

$adresses = Adresses::where('active', 1)->where('user_id',Auth::user()->id)->paginate(10); 
MichalOravec's avatar
$adresses = Adresses::where('active', 1)->where('user_id', Auth::id())->paginate(10); 

return view('adresses.home', compact('adresses'));

or if you have setted relationship

$adresses = Auth::user()->adresses()->where('active', 1)->paginate(10);

return view('adresses.home', compact('adresses'));
Paul_nld's avatar

Thanks option 1 & 3 works for me thanks thanks

Please or to participate in this conversation.