F
Filament4mo ago
Code A

How to show notifications in Filament Admin Panel only (multi-panel setup) triggered by API endpoint

I'm using Laravel with Filament v3, and my app has multiple Filament panels such as Admin, Courier, etc. I want to trigger a notification in the Admin Panel only whenever the mobile app makes a POST request to the /api/orders endpoint to create a new order. I’ve tried calling Notification::make() directly in the API controller, but it doesn’t display anything on the Admin dashboard. I’m guessing it’s because API requests don’t interact with the Filament UI directly. Is there a proper way to trigger real-time notifications in the Filament Admin panel (but not in other panels) when an external event like an API call occurs
8 Replies
toeknee
toeknee4mo ago
So you want to review what your doing, your asking for notifications to be per panel. But I think what you want to do is have them per use that has access to the panel? as at this time notifications are not panel specific. You could override the notifications model and add a panel into the notification class and scope them to panels if you really want to do that.
Code A
Code AOP4mo ago
Well, per user for those who get notifications, for example user A, where user A has access to the admin panel. So, what is the method or flow for that?
toeknee
toeknee4mo ago
Just find all users who have access to panel X, then send a notification to them.
Code A
Code AOP4mo ago
yes I know how to find users who have access to the admin panel, but how to send a notification I use this in the controller when the api create order to the trigger
Notification::make()
->title('title)
->success()
->send();
Notification::make()
->title('title)
->success()
->send();
the result is the notification is not sent I checked the log there is no error, can you give me a reference?
toeknee
toeknee4mo ago
As per: https://filamentphp.com/docs/3.x/notifications/database-notifications
foreach($users as $user) {
Notification::make()
->title('title')
->success()
->sendToDatabase($user);
}
foreach($users as $user) {
Notification::make()
->title('title')
->success()
->sendToDatabase($user);
}
Code A
Code AOP4mo ago
will this Notification::make work if we put it in the Controller? because the trigger is fire?
toeknee
toeknee4mo ago
Doesn't matter at all where the notification is triggered... providing you sent it to the database with the user object.
Code A
Code AOP4mo ago
okay thanks i will try it

Did you find this page helpful?