Posting with Paginated Data

Hi Guys,

I’m building a mini forum and as I post on a paginated thread and refresh the page via livewire, how can I check the current page?

The problem is if I post, exceeding the post per page limit, I need to redirect to page 2 after posting a post, so the user can view there new post, if that makes sense ?

Hey, @AtomCoder

You can use something like that:


Hi @skywalker

How could I use that exactly?

Just show me the code, and I’ll give the right answer

My Render method:

public function render()
  $thread = ForumThreads::where('id', $this->threadID)->with(['posts'])->first();
  $posts = $thread->posts()->paginate($this->paginationCount);

  return view('')->with(compact('thread', 'posts'));

My Post Reply method:

public function postReply()

  # Post Reply
  $test = ForumPosts::create([
    'userID' => Auth::user()->id,
    'threadID' => $this->threadID,
    'description' => $this->reply,

  # Update The Component 

  $this->reply = '';

  # Display Toast
  $this->dispatchBrowserEvent('toast', [
    'message' => 'Reply posted.',
    'type' => 'success',

You can take a look here


Yes I’m aware of those available methods, but my issue is that I need to figure out what page is next and if its a new page specifically, so that I can redirect from my controller method after the post is submitted.