Notification

I am looking to send notifications on a stand alone table (not part of the admin panel). It is a bulk action on a relationship. The action is being run under a DB:: transaction. If the transaction is successful I want to show a notification for success and otherwise I want to show a notification for failure. I have tried to set
->successNotification
(
Notification::make()
->title('Students added.')
->success()
->send()
)
->failureNotification
(
Notification::make()
->title('Students could not be added.')
->warning ()
->send()
)
->successNotification
(
Notification::make()
->title('Students added.')
->success()
->send()
)
->failureNotification
(
Notification::make()
->title('Students could not be added.')
->warning ()
->send()
)
But this shows the notification as soon as the table is loaded. I am not sure how to fix this. Thanks in advance for any possible way to fix it.
5 Replies
wyChoong
wyChoong2y ago
Instead of using this, use failureNotificationTitle and successNotificationTitle
Anish
AnishOP2y ago
Yes - tried those also. Then no notifications are being shown.
Dan Harrin
Dan Harrin2y ago
successNotificationTitle etc are only for our prebuilt actions to enable easier customization for anything custom, you can simply send a notification from within the action() function
Anish
AnishOP2y ago
I guess what you are saying is that once the process part returns whether it is successful or not, I copy the part inside successfulNotification and failureNotification, inside the action call. I will try it out. Thanks for the tip.
Dan Harrin
Dan Harrin2y ago
yeah you have total control over what a "success" or "failure" is
Want results from more Discord servers?
Add your server