From 18288c44b2bf3993a05aad8940344a18bc20f775 Mon Sep 17 00:00:00 2001 From: christophe Date: Tue, 9 Feb 2021 11:19:41 +0100 Subject: [PATCH] Ability to add comment via rate method --- src/Traits/CanRate.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Traits/CanRate.php b/src/Traits/CanRate.php index 34b5479..7453530 100644 --- a/src/Traits/CanRate.php +++ b/src/Traits/CanRate.php @@ -54,13 +54,17 @@ private function rateType($type = null) * * @throws \Exception */ - public function rate($targets, float $amount, $ratingType = null, $class = __CLASS__): array + public function rate($targets, float $amount, $ratingType = null, $comment = null, $comment_user_label = null, $user_avatar = null, $g_id = null, $class = __CLASS__): array { Event::dispatch('acq.ratings.rate', [$this, $targets]); return Interaction::attachRelations($this, 'ratings', $targets, $class, [ 'relation_value' => $amount, 'relation_type' => $this->rateType($ratingType), + 'comment' => $comment, + 'comment_user_label' => $comment_user_label, + 'comment_user_avatar' => $user_avatar, + 'comment_g_id' => $g_id ]); } @@ -95,11 +99,14 @@ public function unrate($targets, $ratingType = null, $class = __CLASS__) * * @throws \Exception */ - public function toggleRate($targets, float $amount, $ratingType = null, $class = __CLASS__) + public function toggleRate($targets, float $amount, $ratingType = null, $comment = null, $comment_user_label = null, $user_avatar = null, $class = __CLASS__) { return Interaction::toggleRelations($this, 'ratings', $targets, $class, [ 'relation_value' => $amount, 'relation_type' => $this->rateType($ratingType), + 'comment' => $comment, + 'comment_user_label' => $comment_user_label, + 'comment_user_avatar' => $user_avatar, ]); }