Skip to content

Commit

Permalink
Ability to add comment via rate method
Browse files Browse the repository at this point in the history
  • Loading branch information
labomatik authored Feb 9, 2021
1 parent 861ee82 commit 18288c4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Traits/CanRate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
]);
}

Expand Down Expand Up @@ -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,
]);
}

Expand Down

0 comments on commit 18288c4

Please sign in to comment.