
here I queried from productionActivity model and have relation with productionOutput model. I want to sum output_kg in production_ouputs table from group by data. i have try with withSum() function but it sum from single data not from all group by data
If you are trying to sum the output_kg from the production_outputs table grouped by some data (assuming it's on production_activity table). then the following should work if the groupBy() function is used correctly and the relationship between the models is defined correctly.