© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
Search
Star
Feedback
Setup for Free
F
Filament
•
3y ago
•
5 replies
ericmp #2
Count relationship quantity via pivot
models
:
ProductPack
Product
ProductPackPivot
(n n table
)
:
pivot extra field
-
> product
_quantity
for each ProductPack i want to know how many products it has
. at the moment im doing it like this
, but this only counts the relationships
:
ProductPack::query()
->withCount('products')
...
ProductPack::query()
->withCount('products')
...
and i need to go to the pivot
, and get the
product_quantity
product_quantity
field instead of counting the relation
im kinda lost on how to achieve it
.
example
:
lets say i have a product pack that has 2 products
:
4 waters
2 forks
the product pack has 2 products
, but really has 4
+2 products
, so i need to get 6 instead of 2
Filament
Join
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Similar Threads
Was this page helpful?
Yes
No
Recent Announcements
Similar Threads
Relationship with pivot
F
Filament / ❓┊help
3y ago
Pivot Select using Relationship
F
Filament / ❓┊help
2w ago
Display count of relationship in table column where pivot value = something
F
Filament / ❓┊help
3y ago
Repeater not saving pivot relationship
F
Filament / ❓┊help
2y ago