I have this table reviews thats stores user's reviews with restaurants id.This is the store function for reviews.i need it to save the average rating and store it in the rating count column
$review = new Review;
$review->user_id = auth()->user()->id;
$review->restaurant_id = $request->get('restaurant_id');
$review->value = $request->input('value');
$review->rating = $request->input('rating');
$avgRating = $review->avg('rating');
$review->rating_count = round($avgRating, 1);
$review->save();
But this saves the rating value for each restaurant, it doesn't calculate the rating and increment it:
Help please, thanks in advance.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2ZiUFq0
via IFTTT
Aucun commentaire:
Enregistrer un commentaire