Table Bulk Action

Is it possible to select record? According to each bulk action . There are three action is applied on the table . (Cancel Record, Archived Record , Send Instant Request ) And there are three status of record - queued , sent , cancelled. Finally i want to select bulk record and perform action accordingly. Cancel Action - Only select those record which are in queued. Archived Action - Only select those record which are not in queued. Send Instant Request - Only select those record which are in queued.
No description
1 Reply
Sourabh
Sourabh4mo ago
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\BulkAction::make('Cancelled selected')
->action(function (Collection $records) {
$queueRecords = $records->filter(function ($record) {
return $record->status === StatusEnum::QUEUED;
});
$queueRecords->each(function ($record) {
$record->status = StatusEnum::CANCELLED;
$record->save();
});
})
->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('is_archived')->label('Archive Selected')
->form([
Forms\Components\Select::make('is_archived')
->label('Archive')
->options(['1' => 'Yes', '0' => 'No'])
->required(),
])->modalWidth('md')
->action(function (array $data, $records) {
// Archive Action code
});
})->deselectRecordsAfterCompletion(),
Tables\Actions\BulkAction::make('send_email')
->label('Send Instant Request')
->action(function (collection $records) {
//Email action
});
});
})->deselectRecordsAfterCompletion()
])->label('Bulk Actions'),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\BulkAction::make('Cancelled selected')
->action(function (Collection $records) {
$queueRecords = $records->filter(function ($record) {
return $record->status === StatusEnum::QUEUED;
});
$queueRecords->each(function ($record) {
$record->status = StatusEnum::CANCELLED;
$record->save();
});
})
->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('is_archived')->label('Archive Selected')
->form([
Forms\Components\Select::make('is_archived')
->label('Archive')
->options(['1' => 'Yes', '0' => 'No'])
->required(),
])->modalWidth('md')
->action(function (array $data, $records) {
// Archive Action code
});
})->deselectRecordsAfterCompletion(),
Tables\Actions\BulkAction::make('send_email')
->label('Send Instant Request')
->action(function (collection $records) {
//Email action
});
});
})->deselectRecordsAfterCompletion()
])->label('Bulk Actions'),
])