Skip to content

Commit 1fc9d87

Browse files
committed
Refactored the data view to have access to the current query before it is paginated
1 parent 9537581 commit 1fc9d87

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Views/DataView.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function applyDefaultFilters()
8585
protected function getRenderData()
8686
{
8787
return [
88-
'items' => $this->query,
88+
'items' => $this->paginatedQuery,
8989
'actionsByRow' => $this->actionsByRow()
9090
];
9191
}
@@ -130,7 +130,7 @@ public function getModelWhoFiredAction($id)
130130

131131
public function updatedAllSelected($value)
132132
{
133-
$this->selected = $value ? $this->query->pluck('id')->map(function ($id) {
133+
$this->selected = $value ? $this->paginatedQuery->pluck('id')->map(function ($id) {
134134
return (string)$id;
135135
})->toArray() : [];
136136
}
@@ -154,7 +154,12 @@ public function getQueryProperty(Searchable $searchable, Filterable $filterable,
154154
$query = $filterable->applyFilters($query, $this->filters(), $this->filters);
155155
$query = $sortable->sortItems($query, $this->sortBy, $this->sortOrder);
156156

157-
return $query->paginate($this->paginate);
157+
return $query;
158+
}
159+
160+
public function getPaginatedQueryProperty()
161+
{
162+
return $this->query->paginate($this->paginate);
158163
}
159164

160165

0 commit comments

Comments
 (0)