Change Bulk Action Visibility Based on Selected Row's field value

Is it possible to change Bulk Action Visiblity based on selected row's attributes? For example, i want to show "Desfazer" Bulk Action only if selected row's Fl_finalizado = true. i tried the following code, but it keeps me showing the error App\Filament\Resources\SorteioResource::App\Filament\Resources{closure}(): Argument #1 ($records) must be of type Illuminate\Support\Collection, null given.

                    ->visible(function (Collection $records) {
                        // Verificando se todas as linhas selecionadas têm fl_finalizado = true
                        return $records->every(fn($record) => $record->fl_finalizado);
                    })


also tried this to avoid the error, but the action never shows:

                   ->visible(function (Collection $records = null) {
                        // Verifica se as linhas selecionadas são válidas
                        if ($records === null) {
                            return false; // Se não houver registros selecionados, retorna false
                        }

                        // Verificando se todas as linhas selecionadas têm fl_finalizado = true
                        return $records->every(fn($record) => $record->fl_finalizado);
                    })
Was this page helpful?