F
Filament9mo ago
Wbzy

How to show Count relationship in table?

What im trying to do: i want to make a report for mutation that happen in the products based on monthly filter. the model is product has many transaction and transaction has one transaction details. the stock in and out is in the transaction details. what i did: because its based on monthly filter so i think i would choose the transactions. this is my base query.
Transaction::query()->with(['product', 'transactionDetail'])->whereHas('transactionDetail')
Transaction::query()->with(['product', 'transactionDetail'])->whereHas('transactionDetail')
my issue is: how to show the product name, and then total stock in from the transaction details and total stock out. i wont to see all the transaction just the product name and the total of mutation.
No description
3 Replies
toeknee
toeknee9mo ago
Add a relationship that does it? So build relationships that will return the in and another for out then you can just pass in ->count()
Wbzy
Wbzy9mo ago
oke i found the solution using
->defaultGroup('category')
->groupsOnly();
->defaultGroup('category')
->groupsOnly();
Wbzy
Wbzy9mo ago
but some how the column doesnt look good
No description