Skip to content

Commit

Permalink
- Resolved Checkbox All Errror when Collection is empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
abhaypithadiya committed Sep 20, 2023
1 parent c0cde09 commit 84a049e
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/Traits/WithCheckbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,24 @@ public function selectCheckboxAll(): void
$actionRulesClass = resolve(ActionRules::class);

/** @phpstan-ignore-next-line */
collect($data->items())->each(function (array|Model|\stdClass $model) use ($actionRulesClass) {
$rules = $actionRulesClass->recoverFromAction('pg:checkbox', $model);

if (isset($rules['hide']) || isset($rules['disable'])) {
return;
}
$value = $model->{$this->checkboxAttribute};

if (!in_array($value, $this->checkboxValues)) {
$this->checkboxValues[] = (string) $value;

$this->dispatchBrowserEvent('pgBulkActions::addMore', [
'value' => $value,
'tableName' => $this->tableName,
]);
}
});
if ($data->isNotEmpty()) {
collect($data->items())->each(function (array|Model|\stdClass $model) use ($actionRulesClass) {
$rules = $actionRulesClass->recoverFromAction('pg:checkbox', $model);

if (isset($rules['hide']) || isset($rules['disable'])) {
return;
}
$value = $model->{$this->checkboxAttribute};

if (!in_array($value, $this->checkboxValues)) {
$this->checkboxValues[] = (string) $value;

$this->dispatchBrowserEvent('pgBulkActions::addMore', [
'value' => $value,
'tableName' => $this->tableName,
]);
}
});
}
}
}

0 comments on commit 84a049e

Please sign in to comment.