F
Filament10mo ago
Jo

Displaying a Modal dialogue in an action instead of a Notification

Here's a simplified version of the code I've written to deduct credits from a user. Is there a straightforward way for the second notification (which is fired on InsufficientCreditsException) to be a modal dialogue instead of a notification? It's all working fine, but the users don't always notice when there's a notification so I want to change it to something a bit more "in your face" which forces the user to read and click a button to dismiss it before they can use the page again.
Action::make('action')
->label("Activate ad")
->action(function (DeductCreditAction $deductCredits) {
try {
$deductCredits(10);
Notification::make()
->title('Sufficient credits. Job active.')
->success()
->send();
} catch (InsufficientCreditsException $e) {
Notification::make()
->title('Sorry, insufficient credits')
->danger()
->send();
}
});
Action::make('action')
->label("Activate ad")
->action(function (DeductCreditAction $deductCredits) {
try {
$deductCredits(10);
Notification::make()
->title('Sufficient credits. Job active.')
->success()
->send();
} catch (InsufficientCreditsException $e) {
Notification::make()
->title('Sorry, insufficient credits')
->danger()
->send();
}
});
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server