Hello
I want to be able to access all the ratings of a category in ecommerce application. here are tables and models:
Category
categories -->>id name
Product
products -->>id name
ProductCategory
product_categories id product_id category_id
Rating
ratings-->>id product_id user_id score
I am using following method in Category model:
public function ratings(){
return $this->hasManyThrough('App\Rating','App\ProductCategory','category_id','product_id','id','id');
}
I have only one category and all the ratings are given to products of that category. but using above method not all rows return from database. is above method correct?
please help
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community