Displaying a modal after action has been performed

Hi - I want to create a table action (like add it on each row) where a user clicks on a button, it performs an action (connection-check in this case) which returns either true or false. Afterwards I want to see a modal with either "success" or "failure". Now from what I get so far, I can create modals BEFORE an action has been performed (like confirmation modals or form-modals), but how do I do that AFTERWARDS? I could do the workarround by opening a modal, adding a button and update said modal, but that is not elegant enough for me. Is there a way to do it like "click button" -> "perform action" -> "show modal with content concering the action-result"?
Thanks in advance. 🙂
Solution
Okay - here is what I ended up with:
Tables\Actions\Action::make('checkConnection')
                    ->label('Verbindung prüfen')
                    ->button()
                    ->action(
                        fn($record) =>
                        Notification::make('checkCon')
                            ->body(function () use ($record){
                                try{
                                    return MyClass::myAction() ? 'Erfolgreich' : 'Fehlgeschlagen';
                                } catch (\Exception){
                                    return 'Fehler';
                                }
                            })
                            ->persistent()
                            ->send()
                    ),

Thanks @toeknee and @ZedoX. 🙂
Was this page helpful?