Laravel: how to get average on nested hasMany relationships (hasManyThrough)
I have three tables: products: id|name|description|slug|category_id|... reviews: id|product_id|review_text|name|email|... review_rows id|review_id|criteria|rating the review table stores the review text, writer of the review and has a foreign product_id key. The review_rows table stores the ratings for different criteria like: ---------------------------------------- | id | criteria | rating | review_id | ---------------------------------------- | 1 | price | 9 | 12 | ---------------------------------------- | 2 | service | 8 | 12 | ---------------------------------------- | 3 | price | 6 | 54