i use paginate method for reviews (that is a relation of Book model) but i can't use links method to navigate between pages.
my code :
Book::with([
'reviews' => fn($query)=> $query->latest()->paginate(5)
])->findOrFail($id)
when i use links method in my view i get below error:
Call to undefined method App\Models\Book::links()
separating the queries is the best option i think, like:
$book = Book::findOrFail($id);
$reviews = $book->reviews()->latest()-
>paginate(5);
then do $reviews->links()
in .blade.php.
thanks to Tim Lewis for answer