mirror of
https://github.com/filamentphp/filament.git
synced 2026-08-28 18:53:05 +08:00
ec1db7c43d
* fix: respect table prefixes in query builder relationship aggregates
* fix: preserve one-of-many relationship semantics in query builder aggregates
* fix: respect relationship method constraints in query builder aggregates
Aggregate subqueries were built from a fresh query on the related model,
so constraints defined inside the relationship method itself were never
applied. An aggregate over a relationship such as
`hasMany(Post::class)->where('is_published', true)` silently aggregated
every related row, and `wherePivot()` on a `BelongsToMany` was ignored
in the same way.
Merge the relationship's own query into the subquery with
`mergeConstraintsFrom()`, matching how Laravel builds its own
`withAggregate()` subqueries.
---------
Co-authored-by: Dan Harrin <git@danharrin.com>