Skip to content

Commit 7512de5

Browse files
committed
Merge branch 'bugfix/bulk-select-with-search' of https://github.com/Majkie/laravel-livewire-tables into Majkie-bugfix/bulk-select-with-search
# Conflicts: # src/Traits/WithBulkActions.php
2 parents 9939041 + e55ca03 commit 7512de5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/Traits/WithBulkActions.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ trait WithBulkActions
1414
public string $primaryKey = 'id';
1515
public bool $selectPage = false;
1616
public bool $selectAll = false;
17-
public $selected = [];
18-
17+
public array $selected = [];
18+
public array $bulkActions = [];
1919
public bool $hideBulkActionsOnEmpty = false;
2020

2121
public function renderingWithBulkActions(): void
@@ -49,7 +49,7 @@ public function updatedSelectPage($value): void
4949

5050
public function selectPageRows(): void
5151
{
52-
$this->selected = $this->rows->pluck($this->primaryKey)->map(fn ($key) => (string) $key);
52+
$this->selected = $this->rows->pluck($this->primaryKey)->map(fn ($key) => (string) $key)->toArray();
5353
}
5454

5555
public function selectAll(): void
@@ -69,8 +69,10 @@ public function resetBulk(): void
6969
*/
7070
public function selectedRowsQuery()
7171
{
72-
return (clone $this->rowsQuery())
73-
->unless($this->selectAll, fn ($query) => $query->whereIn($query->qualifyColumn($this->primaryKey), $this->selected));
72+
return $this->query()->unless(
73+
$this->selectAll,
74+
fn ($query) => $query->whereIn($query->qualifyColumn($this->primaryKey), $this->selected)
75+
);
7476
}
7577

7678
/**
@@ -83,7 +85,7 @@ public function getSelectedRowsQueryProperty()
8385

8486
public function selectedKeys(): array
8587
{
86-
return $this->selectedRowsQuery()->pluck($this->rowsQuery()->qualifyColumn($this->primaryKey))->toArray();
88+
return $this->selectedRowsQuery()->pluck($this->query()->qualifyColumn($this->primaryKey))->toArray();
8789
}
8890

8991
public function getSelectedKeysProperty(): array

0 commit comments

Comments
 (0)