You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to implement a custom toast notification when deleting a record in the ListBeritas page of my Filament resource. I have already created a function to customize the toast notification for successful data saves in the EditBerita page, as shown below:
EditBerita.php
protected function getSavedNotification(): ?Notification
{
return Notification::make()
->success()
->title('Data Berhasil Disimpan')
->color('success');
}
I want to implement a similar notification for deleting a record in the ListBeritas page. Here's the code I've tried so far: ListBerita.php
<?php
namespace App\Filament\Resources\BeritaResource\Pages;
use App\Filament\Resources\BeritaResource;
use Filament\Actions;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\ListRecords;
class ListBeritas extends ListRecords
{
protected static string $resource = BeritaResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make()->label('Tambah Berita'),
];
}
protected function getDeletedNotification(): ?Notification
{
return Notification::make()
->success()
->title('Data Berhasil Dihapus')
->color('success');
}
// Override delete action to include custom notification
protected function getActions(): array
{
return [
Actions\DeleteAction::make()->label('')
->after(function ($record) {
// Trigger the notification after successful deletion
$this->getDeletedNotification()->send();
}),
];
}
}
However, it seems that the custom notification doesn't show up when I delete a data row. I need assistance in making sure that the notification for data deletion works properly, just like the one for saving data.
Has anyone implemented a custom toast notification for deletions in Filament resources? Any help or suggestions would be appreciated! @leandrocfe
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Package
Notifications
Package Version
v3.2
How can we help you?
I'm trying to implement a custom toast notification when deleting a record in the ListBeritas page of my Filament resource. I have already created a function to customize the toast notification for successful data saves in the EditBerita page, as shown below:
EditBerita.php
I want to implement a similar notification for deleting a record in the ListBeritas page. Here's the code I've tried so far:
ListBerita.php
However, it seems that the custom notification doesn't show up when I delete a data row. I need assistance in making sure that the notification for data deletion works properly, just like the one for saving data.
Has anyone implemented a custom toast notification for deletions in Filament resources? Any help or suggestions would be appreciated!
@leandrocfe
Beta Was this translation helpful? Give feedback.
All reactions