Update related table
I have a custom action which opens a modal, and create records in a related table. I would like to emit a event to update the related table after the record is created. Is there any way to do this?
My NoteResource:
"
->schema([
Actions::make([
Action::make('Send epost')
->disabled(fn(string $operation) :bool => $operation === 'create')
->form([
TextInput::make('type')
->required()
->placeholder(fn ($record) => $record->body)
->maxLength(255),
Forms\Components\Textarea::make('content'),
Forms\Components\TextInput::make('customer_id')
->default(fn ($record) => $record->customer_id ?? null),
Forms\Components\TextInput::make('note_id')
->default(fn ($record) => $record->id ?? null),
])
->action(function (array $data, string $model): Conversation {
Notification::make()
->success()
->title('Epost sendt')
->send();
return Conversation::create($data);
}),
Action::make('Send sms')
->color('gray')
->action(function () {
// do something
}),
Action::make('Nytt notat')
->color('gray')
->action(function () {
// do something
})
]),"
2 Replies
In your relation manager(s) add a listener like ...
... and emit/dispatch it in your action ...
You didn't say if you are using v2 or v3. In v3, it would be $this->dispatch().
Thanks. I´m using V3. Got it working with this solution:
' #[On('refreshConversation')]
public function refresh(): void
{
}'