Skip to content

Commit

Permalink
Merge wheres to hasQuery for withCount()
Browse files Browse the repository at this point in the history
Fixes missing wheres defined on the relation, see laravel/framework#13414 (comment)
  • Loading branch information
barryvdh committed May 18, 2016
1 parent 7443dcb commit 5c3b162
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,7 @@ public function withCount($relations)
$relation->getRelated()->newQuery(), $this
);

$this->mergeModelDefinedRelationWheresToHasQuery($query, $relation);
call_user_func($constraints, $query);

$this->selectSub($query->getQuery(), snake_case($name).'_count');
Expand Down

0 comments on commit 5c3b162

Please sign in to comment.