Open kskrlin opened 8 years ago
I am also curious how this might be done. Currently trying to find a solution and will update.
Here is my solution. I added a resetCriteria function to the base Repository class.
I replace Criteria with an empty Collection, apply it, then recreate the model.
...
public function resetCriteria()
{
$this->criteria = new Collection;
$this->applyCriteria();
$this->makeModel();
return $this;
}
...
How to call more then 1 Criteria inside the controller method? For example, I want to get separated active and inactive users (status is checked between 2 tables and a few where clauses). If I use: $active = $this->user->getByCriteria(new GetActiveUsers($role_id))->all(); and $inactive = $this->user->getByCriteria(new GetInactiveUsers($role_id))->all(); the second one just appends Criteria GetInactiveUsers on the above query.
How to reset query data in this example?