Deselect if bulk action cancel

How to deselect records if bulk action is cancelled.
Tables\Actions\BulkAction::make('Cancelled selected')
                        ->before(function ($records, Tables\Actions\BulkAction $action) {
                            $queueRecords = $records->filter(function ($record) {
                                return $record->status === StatusEnum::QUEUED;
                            })->chunk(100)->flatten();
                            if ($queueRecords->count() == 0) {
                                Notification::make()
                                    ->title("No record found to be cancelled.")
                                    ->info()
                                    ->send();
                                $action->cancel();
                            }
                        })
                        ->action(function (Collection $records) {
                            $queueRecords = $records->filter(function ($record) {
                                return $record->status === StatusEnum::QUEUED;
                            });
                            $queueRecords->each(function ($record) {
                                $record->status = StatusEnum::CANCELLED;
                                $record->save();
                            });
                            Notification::make()->title('Selected review queue has been cancelled successfully')->success()->send();
                        })
                        ->requiresConfirmation()
                        ->modalDescription('This action is to cancel the selected review queue.Only if the status queued is available.Do you want to continue?.')
                        ->deselectRecordsAfterCompletion(),
image.png
Was this page helpful?