F
Filament15mo 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
HasithOP15mo ago
This way is not working as expected
toeknee
toeknee15mo ago
You need to send it ->send()
Hasith
HasithOP15mo 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
HasithOP15mo ago
Thank you
Want results from more Discord servers?
Add your server