F
Filament11mo ago
Sourabh

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(),
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(),
No description
1 Reply
Sourabh
SourabhOP11mo ago
I found the solution .
->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->getLivewire()->deselectAllTableRecords();
$action->cancel();
}
})
->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->getLivewire()->deselectAllTableRecords();
$action->cancel();
}
})
Want results from more Discord servers?
Add your server