© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
dotdotdot

Sum relationship

I have a User model and a Course model. with a relationship between them, this relationship is defined as "enrollment" (enrollment is basically the pivot table of the relationship)

I have made a filament resource for enrollments.

I want to get the sum of the costs of all courses

If I use the default
Sum
Sum
, I get the unique sum like so:

enrollments table:
id | user_id | course_id|
1  | 1       | 32       |
2  | 1       | 36       |
3  | 2       | 32       |
enrollments table:
id | user_id | course_id|
1  | 1       | 32       |
2  | 1       | 36       |
3  | 2       | 32       |

this currently returns the following
cost of course 32 + cost of course 36
cost of course 32 + cost of course 36
.

but what I want is to return
cost of course 32 + cost of course 36 + cost of course 32
cost of course 32 + cost of course 36 + cost of course 32
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Export with aggregating relationship (sum)
FilamentFFilament / ❓┊help
6d ago
How to Sum relationship column with cast field
FilamentFFilament / ❓┊help
15mo ago
multiple relationships with ->relationship()
FilamentFFilament / ❓┊help
3y ago
Table Column Relationship Sum, Avg, Max, Min, ext being ignored
FilamentFFilament / ❓┊help
2y ago