F
Filamentβ€’17mo ago
Atena.D

Send database notification for any change in a table.

Hi. I wanted to know how can I send database notification to admin panel whenever one of my table changes e.g. one record deleted, added or created. I read https://filamentphp.com/docs/2.x/notifications/database-notifications but I was just able to add the notification bell to admin panel and I couldn't listen to database changes
Filament
Database notifications - Notifications - Filament
Elegant TALL stack notifications for Laravel artisans.
12 Replies
toeknee
toekneeβ€’17mo ago
I am not sure I follow? The docs explain it, so when you delete you need to send the notification with sendToDatabase(). Ensure you have polling enabled if you want them to show to the user without refreshing the page
Atena.D
Atena.Dβ€’17mo ago
should I use Notification::make() whenever an update, delete or create happened? I mean is there any way that I can listen for them instead of adding the same line of code in each of them?
Dan Harrin
Dan Harrinβ€’17mo ago
use a model observer? then you can do it all in one place
Atena.D
Atena.Dβ€’17mo ago
Nice idea! Thanks. πŸ‘
toeknee
toekneeβ€’17mo ago
Good shout Dan
Unknown User
Unknown Userβ€’16mo ago
Message Not Public
Sign In & Join Server To View
toeknee
toekneeβ€’16mo ago
Are you sendign them to the database?
Unknown User
Unknown Userβ€’16mo ago
Message Not Public
Sign In & Join Server To View
Dan Harrin
Dan Harrinβ€’16mo ago
the data is wrong i guess you didnt send the database notification using filament? you need to use our Notification::make() api otherwise the data isnt structured
Unknown User
Unknown Userβ€’16mo ago
Message Not Public
Sign In & Join Server To View
Dan Harrin
Dan Harrinβ€’16mo ago
how do we render a database notification that we know nothing about?
Unknown User
Unknown Userβ€’16mo ago
Message Not Public
Sign In & Join Server To View