count of field on relationship
Good day all. I am trying to show a field in a table which lists a total amount (integer) of a field on a relationship. I got "Tables\Columns\TextColumn::make('stocks.amount'),", which works, but it shows 100, 200, 500 etc. I just want to display the single total count of those, instead of individual numbers of each relation record. I have read the docs, but i seem unable to find a correct answer for it. Im sure im missing something, or have overlooked it perhaps? But if someone could enlighten me, i would be grateful!
2 Replies
I think this should work?
It is explained here:
https://filamentphp.com/docs/3.x/tables/columns/relationships#aggregating-relationships
Works perfectly! I did try this, but my error seems to have been that i did not rename the field from stocks.amount.
Thank you!