So I have two Livewire components,
I want to emit the result of this function to another component;
public function loanCal()
{
if ($staff = Staffrecord::where('staff_id', $this->staff_id)
->first()
) {
$this->loanDeduction = [];
foreach ($staff->loans as $loan) {
foreach ($loan->loantype as $loan_name) {
$this->loanDeduction[] = ['loan_amount' => $loan->loan_amount / $this->loanDuration, 'loantype' => $loan_name->name];
}
}
return $this->loanDeduction;
**$this->emit('updated', $this->loanDeduction);**
}
On the Second Component
I have my Listener setup as so
protected $listeners = [âupdatedâ];
public function updated($LoanData)
{
dd($LoanData);
}
But when ever the line of $this->emit(âupdatedâ, $this->loanDeduction); is executed nothing happens.
My Pay is how do I pass the result from a function from one livewire component to another