Widget Table BulkAction
I have a problem when i use a bulkaction on a WidgetAction, no matter what selected, everything get selected and updated, any idea what the solution?
BulkAction::make("mark_payed")
->translateLabel()
->icon("heroicon-c-check-circle")
->iconPosition(IconPosition::Before)
->iconSize(IconSize::Small)
->color("success")
->requiresConfirmation()
->modalHeading(__("mark as payed"))
->modalDescription(__("sure to mark payed?"))
->modalSubmitActionLabel(__("Yes, mark it payed"))
->action(function(Collection $records,array $data, HasTable $livewire){
$now = Carbon::now();
foreach ($records as $record){
$record->update([
'order_product_is_com_payed' => 1,
"order_product_date_com_payed" => $now
]);
$record->save();
$livewire->getTableRecords();
}
})
->deselectRecordsAfterCompletion(),BulkAction::make("mark_payed")
->translateLabel()
->icon("heroicon-c-check-circle")
->iconPosition(IconPosition::Before)
->iconSize(IconSize::Small)
->color("success")
->requiresConfirmation()
->modalHeading(__("mark as payed"))
->modalDescription(__("sure to mark payed?"))
->modalSubmitActionLabel(__("Yes, mark it payed"))
->action(function(Collection $records,array $data, HasTable $livewire){
$now = Carbon::now();
foreach ($records as $record){
$record->update([
'order_product_is_com_payed' => 1,
"order_product_date_com_payed" => $now
]);
$record->save();
$livewire->getTableRecords();
}
})
->deselectRecordsAfterCompletion(),