DEV Community

Discussion on: Someone could help me about calculations in blade views?

Collapse
 
chrisrhymes profile image
C.S. Rhymes

There might be a collection method you could use on your models to make it easier for you. You could try chaining them, such as where and sum.

$grades->where(‘subject’, ‘history’)->sum(‘score’)

Laravel collections

Collapse
 
gustavojordanra profile image
Gustavo Jordan

I already think in that but it will only return the grades for the history subject acumulated, so how I pass all the results to the view, I need to pass all the subjects, like this but I need to group the results by subject and then pass to the view