Hi everyone
I want to implement a star rating system for my products, but I do not have the experience to do so. Training for this topic, if any, please give me the link. Thank you.
I created model and migration for rating (with: rating, rating title, rating body, foreign id to user and foreign id to product)
In products model, I just created a function called ratingAverage to calculate the sum/average rating of a products
e.g
public function ratingAverage()
{
return $this->rating->avg('rating');
}
Lastly, use sass to to style the stars as you can pass in the value of the rating dynamically from the blade view by calling the ratingAverage method on a product you are displaying.
You can style the stars whatever way you choose, but I used sass.