You can grab all posts, paginate them and get last page with helper method lastPage()
https://laravel.com/docs/5.2/pagination#displaying-results-in-a-view
I have a simple process where users submit posts to a thread. A controller stores the new post and redirects them back to the thread along with an anchor to the new post:
return redirect('thread/' . $thread->id . '#post-' . $post->id);
// http://domain.com/thread/23#post-45
Here's my problem...
Threads are currently paginated with 20 posts per page. When it redirects back to the thread, unless the new post is on the first page, the anchor obviously doesn't work and the user cannot see the post they just submitted.
Is there a way to always redirect to the LAST page in the threads pagination?
Thanks.
Please or to participate in this conversation.