Change $post to $this->post that should do it.
Aug 15, 2022
4
Level 1
[Solved] Send parameter to a livewire component controller
Hi everyone!
I have a Post Model, and I need navigate in my app admin control panel, for all specific user posts. I have a livewire component called PostsList and I'm trying to send a $post variable to use this varibale to determine which user belongs to.
My livewire component is like this:
use Livewire\Component;
use App\Models\Post;
use App\Models\User;
class Edit extends Component
{
public $post;
public function render()
{
//this dump get an 'Undefined variable $post' error
dump($post);
//I need get the post user:
$user = $post->user;
return view('livewire.admin.articles.edit', compact('user','article'));
}
}
And I'm calling the livewire component like this:
//This dump show the post model perfect
@dump($post)
@livewire('admin.posts.edit', ['post' => $post])
However, whith dump($post) in the controller, I get an Undefined variable $post error...
How I can send the $post variable to the livewire component Controller?
Level 37
2 likes
Please or to participate in this conversation.