// change this method to public...
private function refreshMe()
{
dd(__METHOD__);
}
Livewire Emit event not working
Hi - I have a Livewire component that generates and processes a payment form. I have a second livewire component that generates a check register table. I want the check register table to be regenerated every time a payment form is processed. Both the form and the table are initially generated correctly and upon refresh. Here's the code for the payment processing:
public function updateSchoolpayment()
{
$validated = $this->validate([
'amount' => ['required','numeric'],
'comments' => ['nullable','string'],
]);
Schoolpayment::create(
[
'eventversion_id' => $this->eventversion->id,
'school_id' => $this->targetschool->id,
'user_id' => $this->userid,
'amount' => $this->amount,
'comments' => $this->comments,
'updated_by' => auth()->id(),
],
);
$this->emit('refreshcheckregister');
$this->reset();
}
and here's the model for the check register table:
class SchoolpaymentrosterComponent extends Component
{
protected $listeners = ['refreshcheckregister' => 'refreshMe'];
public function render()
{
return view('livewire.schoolpaymentroster-component',
[
'payments' => $this->schoolPayments(),
]);
}
private function schoolPayments()
{
return Schoolpayment::with('person','school')
->where('eventversion_id', Userconfig::getValue('eventversion', auth()->id()))
->get();
}
private function refreshMe()
{
dd(__METHOD__);
}
}
Nothing happens after the payment is processed except for the form restoring default values. I can't tell if there's an error with the emit or with the listener, but I know I'm making some simple error. All guidance is appreciated!
Please or to participate in this conversation.