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
This way is not working as expected
You need to send it
->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();
}),
])
->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();
}),
])
Thank you