My Render method:
public function render()
{
$thread = ForumThreads::where('id', $this->threadID)->with(['posts'])->first();
$posts = $thread->posts()->paginate($this->paginationCount);
return view('livewire.forum.thread')->with(compact('thread', 'posts'));
}
My Post Reply method:
public function postReply()
{
$this->validate();
# Post Reply
$test = ForumPosts::create([
'userID' => Auth::user()->id,
'threadID' => $this->threadID,
'description' => $this->reply,
]);
# Update The Component
$this->emit('refreshPosts');
$this->reply = '';
# Display Toast
$this->dispatchBrowserEvent('toast', [
'message' => 'Reply posted.',
'type' => 'success',
]);
}