Skip to content

Commit

Permalink
Fixed a bug getting the model who fired an action, needed to clone qu…
Browse files Browse the repository at this point in the history
…e initial query
  • Loading branch information
Gustavinho committed Jun 24, 2021
1 parent ad7fb7c commit c648467
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Views/DataView.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,13 @@ public function getActions()
return $this->actionsByRow();
}

/**
* Clones the initial query (to avoid modifying it)
* and get a model by an Id
*/
public function getModelWhoFiredAction($id)
{
return $this->initialQuery->find($id);
return (clone $this->initialQuery)->find($id);
}

public function updatedAllSelected($value)
Expand All @@ -145,7 +149,7 @@ public function getInitialQueryProperty()
*/
public function getQueryProperty(Searchable $searchable, Filterable $filterable, Sortable $sortable)
{
$query = $this->initialQuery;
$query = clone $this->initialQuery;
$query = $searchable->searchItems($query, $this->searchBy, $this->search);
$query = $filterable->applyFilters($query, $this->filters(), $this->filters);
$query = $sortable->sortItems($query, $this->sortBy, $this->sortOrder);
Expand Down

0 comments on commit c648467

Please sign in to comment.