i got the annonces from a user authenticator, and i want to do pagination but i don’t know how.
UsersController.php
public function index() { $annonces = Auth::user()->annonces; $users = User::find(Auth::user()->id); return view('users.index')->with([ 'users' => $users, 'annonces' => $annonces ]); }
Advertisement
Answer
public function index() { $user = Auth::user(); $annonces = $user->annonces()->paginate(5); return view('users.index', [ 'user' => $user, 'annonces' => $annonces ]); }