Skip to content

Commit c648467

Browse files
committed
Fixed a bug getting the model who fired an action, needed to clone que initial query
1 parent ad7fb7c commit c648467

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Views/DataView.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,13 @@ public function getActions()
119119
return $this->actionsByRow();
120120
}
121121

122+
/**
123+
* Clones the initial query (to avoid modifying it)
124+
* and get a model by an Id
125+
*/
122126
public function getModelWhoFiredAction($id)
123127
{
124-
return $this->initialQuery->find($id);
128+
return (clone $this->initialQuery)->find($id);
125129
}
126130

127131
public function updatedAllSelected($value)
@@ -145,7 +149,7 @@ public function getInitialQueryProperty()
145149
*/
146150
public function getQueryProperty(Searchable $searchable, Filterable $filterable, Sortable $sortable)
147151
{
148-
$query = $this->initialQuery;
152+
$query = clone $this->initialQuery;
149153
$query = $searchable->searchItems($query, $this->searchBy, $this->search);
150154
$query = $filterable->applyFilters($query, $this->filters(), $this->filters);
151155
$query = $sortable->sortItems($query, $this->sortBy, $this->sortOrder);

0 commit comments

Comments
 (0)