F
Filament10mo ago
Hasith

Notification inside a table action

How can i add notification inside an action?
->actions([

Tables\Actions\ViewAction::make(),
TableAction::make('delete')
->requiresConfirmation()
->color('danger')
->icon('heroicon-s-trash')
->action(function (User $record) {

Log::info($record);
if($record->id == 1){
Notification::make()
->success()
->title('User deleted')
->body('The user has been deleted successfully.');
}else{
return;
}

}),
])
->actions([

Tables\Actions\ViewAction::make(),
TableAction::make('delete')
->requiresConfirmation()
->color('danger')
->icon('heroicon-s-trash')
->action(function (User $record) {

Log::info($record);
if($record->id == 1){
Notification::make()
->success()
->title('User deleted')
->body('The user has been deleted successfully.');
}else{
return;
}

}),
])
4 Replies
Hasith
Hasith10mo ago
This way is not working as expected
toeknee
toeknee10mo ago
You need to send it ->send()
Hasith
Hasith10mo ago
->actions([

Tables\Actions\ViewAction::make(),
TableAction::make('delete')
->requiresConfirmation()
->color('danger')
->icon('heroicon-s-trash')
->action(function (User $record) {

// Log::info($record);

Notification::make()
->warning()
->title('User deleted')
->body('The user has been deleted successfully.')
->send();

}),
])
->actions([

Tables\Actions\ViewAction::make(),
TableAction::make('delete')
->requiresConfirmation()
->color('danger')
->icon('heroicon-s-trash')
->action(function (User $record) {

// Log::info($record);

Notification::make()
->warning()
->title('User deleted')
->body('The user has been deleted successfully.')
->send();

}),
])
Hasith
Hasith10mo ago
Thank you
Want results from more Discord servers?
Add your server
More Posts