XF 2.2 Edit Review Resources

Robert9

Well-known member
There is an add-on from AndyB to edit the message of RM reviews.
Today i have done the add-on for my own as an extension for ResourceReview.
Now i can change the message and rating.

For my next step i need to know how to update the rating for the resource itself.

Is there any fast function like "rebuild rating for resource 123" ?
 
Code:
        $resource = $review->Resource;
        $resource->rebuildRating();

        $ratingAvg = $resource->rating_sum / $resource->rating_count;
        $ratingAvg = round($ratingAvg, 2);


        $resource->fastUpdate([
            'rating_sum' => $resource->rating_sum,
            'rating_avg' => $ratingAvg
        ]);

Seems that rebuildRating() only recalculate the sum.
 
Back
Top Bottom