Override the PHP file of database notifications drawer livewire component
I want to override the PHP file of this livewire component (database notifications drawer):
https://user-images.githubusercontent.com/14108109/273273479-ca1a171a-1c0f-4485-9e2c-3982a3bb2d3d.png
What I want is to edit the actions of the buttons on the drawer (Clear, Mark all as read...)
The class in in vendor/Filament/Notifications/src/Livewire, it's called DatabaseNotifications.php
Solution:Jump to solution
i write a post about this case, u can see this post
Rupadana
Filamentphp 3 : Custom Database Notification Actions | Rupadana
Personal website, portfolio, blog, software engineer roadmap, programming tips of rupadana
22 Replies
Thanks @Vp but those pages do not answer my question
Ok, I think you need to check this https://filamentphp.com/docs/3.x/notifications/customizing-notifications
That doesn't answer my answer neither
Then maybe explain what you want better?
U can create a new class, extend the DatabaseNotification and override the method
Yeah sure, I want to edit the actions of the buttons: Mark all as read, clear and the X button of the notification, basically what I want is to overwrite the class vendor/Filament/Notifications/src/Livewire/DatabaseNotifications.php, which is the PHP file of the notification drawer livewire component.
Reason: those buttons are are using mass assignment to change the notifications which means no events will be triggered but I want the events to be triggered.
Yes I can do that, but how I will tell Filament to use my new class?
If you're using the notifications package with a standalone page you can use a custom view instead of
database-notifications
that uses your extended class. But I'm not sure there's an easy way to do it with a panel... Another option is making a PR to add events to the methods in DatabaseNotifications
Solution
i write a post about this case, u can see this post
Rupadana
Filamentphp 3 : Custom Database Notification Actions | Rupadana
Personal website, portfolio, blog, software engineer roadmap, programming tips of rupadana
How are you removing the default
database-notifications
component from the panel? As far as I can tell it's hardcoded in all the views:
https://github.com/filamentphp/filament/blob/062b13a724743b720ee488cdf380505f087e7fa4/packages/panels/resources/views/components/topbar/index.blade.php#L132
So by adding @livewire('database-custom-notifications')
, aren't you just opening a second modal over the top of the default one?in my case, the database-notifications need manual registered
which version included this?
u can set databaseNotification to false in the panel provider
but, if many people need to override DatabaseNotification livewire, it better to add some method to custom it in panel provider
adding this method to HasNotification trait
and then call it here
or simply like this
maybe we need to create a
PR
GitHub
Custom DatabaseNotifications Livewire by rupadana · Pull Request #8...
This PR add new parameter to databaseNotification in HasNotification trait and modify some topbar/index.blade.php
Changes have been thoroughly tested to not break existing functionality.
New fu...
That should work, thanks so much, I will give it a try
Great addition, thank you
You're welcome
reminder: the mass assignment is done for performance. in your implementation, you should use a queue
thnks