how to trigger notification on a custom bulkaction?
Tables\Actions\BulkAction::make('toggleStatus')
->label('Toggle Status')
->icon('heroicon-o-arrow-path')
->requiresConfirmation()
->action(function (Collection $records) {
$records->each(function (User $user) {
$user->update(['is_active' => !$user->is_active]);
});
})
->deselectRecordsAfterCompletion()
->successNotification(
Notification::make()
->success()
->title('User status updated')
->body('The selected users\' statuses have been toggled.')
),Tables\Actions\BulkAction::make('toggleStatus')
->label('Toggle Status')
->icon('heroicon-o-arrow-path')
->requiresConfirmation()
->action(function (Collection $records) {
$records->each(function (User $user) {
$user->update(['is_active' => !$user->is_active]);
});
})
->deselectRecordsAfterCompletion()
->successNotification(
Notification::make()
->success()
->title('User status updated')
->body('The selected users\' statuses have been toggled.')
),Solution
you can just move notification to action like this
->action(function (Collection $records) {
$records->each(function (User $user) {
$user->update(['is_active' => !$user->is_active]);
});
Notification::make()
->success()
->title('User status updated')
->body('The selected users\' statuses have been toggled.')
->send();
})->action(function (Collection $records) {
$records->each(function (User $user) {
$user->update(['is_active' => !$user->is_active]);
});
Notification::make()
->success()
->title('User status updated')
->body('The selected users\' statuses have been toggled.')
->send();
})