F
Filament5mo ago
eno7x

notification

Hello. How can I send a notification to the user about a content whose status has been updated from the admin panel so that they can learn the status of this update from the user's panel?
7 Replies
eno7x
eno7xOP5mo ago
Is there an example of how I can send this from the admin panel to the user's panel? I use two separate panels in Filament. One is the admin panel and the other is a user panel with tenancy. :squint:
toeknee
toeknee5mo ago
Yes as per the above, tenancy is irrelevant for notifications, it's based on the users_id
eno7x
eno7xOP5mo ago
Thanks for the help. Here's what I did. I save a message to the database with a button on the View page and send it to the user with the following codes. Is this approach correct? I'm trying to write clean code.
protected function getHeaderActions(): array
{
return [
Actions\Action::make('adminNote')
->label('Düzenleme Talebi Ekle')
->fillForm(fn(Blog $record): array => [
'admin_note' => $record->admin_note,
])
->form([
Textarea::make('admin_note')->autosize()->rows(5)->hiddenLabel(),
])
->action(function (array $data, Blog $record): void {
$record->admin_note = $data['admin_note'];
$record->save();
if ($record->save()) {
Notification::make()->title('Saved successfully')->success()->send();

Notification::make()
->title('A database notification has been created')
->body($data['admin_note'])
->sendToDatabase(User::find(3));
}
}),
Actions\DeleteAction::make()->label('Kalıcı Olarak Sil'),
];
}
protected function getHeaderActions(): array
{
return [
Actions\Action::make('adminNote')
->label('Düzenleme Talebi Ekle')
->fillForm(fn(Blog $record): array => [
'admin_note' => $record->admin_note,
])
->form([
Textarea::make('admin_note')->autosize()->rows(5)->hiddenLabel(),
])
->action(function (array $data, Blog $record): void {
$record->admin_note = $data['admin_note'];
$record->save();
if ($record->save()) {
Notification::make()->title('Saved successfully')->success()->send();

Notification::make()
->title('A database notification has been created')
->body($data['admin_note'])
->sendToDatabase(User::find(3));
}
}),
Actions\DeleteAction::make()->label('Kalıcı Olarak Sil'),
];
}
toeknee
toeknee5mo ago
Yeah that's good
eno7x
eno7xOP5mo ago
Thank you very much for your help

Did you find this page helpful?