F
Filamentβ€’7mo ago
Jakub

Refreshing ParentResource Infolist when adding records in RelationManager table

What I want to do When I add a new record on a table that is added via relation manager. I want the parent resource data to update and reflect the new changes. I have a PhoneMembership->balance() calculcator on the infolist, that i would like to get updated without manually refreshing the page each time. Right now, after a new record is added to the table. I would need to manually refresh the page for the new balance to show up. First I tried doing this approach that I found here https://discord.com/channels/883083792112300104/1209193801386827776
Tables\Actions\Action::make('quick-payment')->label('Quick Payment')
->action(function () {
$this->ownerRecord->phoneMembershipRecords()->create([
// stuff
]);

$this->dispatch('$refresh')->to(ViewPhoneMembership::class);
})
Tables\Actions\Action::make('quick-payment')->label('Quick Payment')
->action(function () {
$this->ownerRecord->phoneMembershipRecords()->create([
// stuff
]);

$this->dispatch('$refresh')->to(ViewPhoneMembership::class);
})
Next I tried to do https://discord.com/channels/883083792112300104/1103674797537366167
use Livewire\Component;

->action(function (Component $livewire) {
$this->ownerRecord->phoneMembershipRecords()->create([
//stuff
]);

$livewire->emit('refresh-view-phone-membership');
})
use Livewire\Component;

->action(function (Component $livewire) {
$this->ownerRecord->phoneMembershipRecords()->create([
//stuff
]);

$livewire->emit('refresh-view-phone-membership');
})
On the ViewPhoneMembership I added
protected $listeners = ['refresh-view-phone-membership' => '$refresh'];
protected $listeners = ['refresh-view-phone-membership' => '$refresh'];
I get this error for BadMethodCallException
Solution:
$this->dispatch('updatePhoneMembershipTable'); lol instead emit...
Jump to solution
3 Replies
Jakub
JakubOPβ€’7mo ago
If it helps with the context
No description
Jakub
JakubOPβ€’7mo ago
- add quick payment which adds a new transaction - emit some event to update accout balance in the top left panel, which is from the PhoneMembershipResource infolist Any help or insight on where I could find the answer is much appreciated πŸ™‚
Solution
Jakub
Jakubβ€’7mo ago
$this->dispatch('updatePhoneMembershipTable'); lol instead emit
Want results from more Discord servers?
Add your server