I have a User model, who hasMany categories and category hasMany posts and post hasOne Product
Now I want to sum all of the product->price of Auth::user()
how can i do that withSum or withCount function. in Laravel
I have a User model, who hasMany categories and category hasMany posts and post hasOne Product
Now I want to sum all of the product->price of Auth::user()
how can i do that withSum or withCount function. in Laravel
Copyright © 2021 Jogjafile Inc.
Since your question doesnt present any details, I will assume that you have all the relations well set up.
You can get the sum using the relations like this