In a view I include a livewire component like so:
<livewire:search-comments :post="$post">
I can pass in the post as shown above. But the problem is that this is only done on mount():
public function mount($post)
{
$this->post = $post;
}
In render(), I have:
$comments = $this->post->comments()
->where('comment', 'like', "%{$this->search}%")
->get()
The problem is that I need to access $post on every render() call, because the comments searched are tied to the post the user is currently on. I could pass the post ID in a hidden field but that doesn't feel like the right (and a safe..?) solution.