repository icon indicating copy to clipboard operation
repository copied to clipboard

findWhere after Criteria

Open carlituxman opened this issue 9 years ago • 3 comments

I'm doing a criteria before a query like:

$all = $this->repo->findWhere(['status_id'=> $status->id, 'user_id'=> 1])->count();

my criteria is like this:

public function apply($model, Repository $repository) { $users = User::filtered()->lists('id')->toArray(); $model = $model->where('user_id', $users); return $model; }

the result of criteria is correct, but when I do the findWhere after it returns 0 (and should be return more)

carlituxman avatar Dec 26 '15 10:12 carlituxman

the problem is because I have a loop after the criteria, only do it well in the first iteration

I'm researching what's happen...

the problem is because (I think) the criteria apply in every loop again

carlituxman avatar Dec 26 '15 10:12 carlituxman

The problem is because in every iteration the query is stacked I solve using: $this->repo->skipCriteria(); $this->repo->pushCriteria(new myCriteria());

in every iteration

carlituxman avatar Dec 26 '15 11:12 carlituxman

this should be cleared in every find, findWhere, ... ??

carlituxman avatar Dec 26 '15 11:12 carlituxman