Count SaleItems sold by Product ID
Hello, I have a Sales Resource with (hasMany) SaleItems Resource which selects a product to sell from the Product table. I'm looking to have a column in my Product table that sums all the related product sales to give a Sold total.
I've read through the docs and finding this particular issue to be a little tricky. Any help is appreciated!
8 Replies
migrations



product table?

I think you should create an attribute and count the sum there
Thank you @krekas, I'll look into that!
Take a look at
withSum
And please dont use decimal/floats for currency values
And next time please use real code and not images πThanks @dissto! Sorry!
@dissto From what I'm seeing, withCount will count the amount of relationships, right?
Yes, but I wrote to take a look at
withSum
not withCount
πHaha, oops! Thank you