Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
KyrneDev authored and StyleCIBot committed Mar 20, 2020
1 parent 084f20e commit a49c749
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/Listener/AddPostReactionsRelationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ public function subscribe(Dispatcher $events)
public function getModelRelationship(GetModelRelationship $event)
{
if ($event->isRelationship(Post::class, 'reactions')) {
return $event->model->belongsToMany(Reaction::class, 'post_reactions', 'post_id')->withPivot('reaction_id',
'user_id');
return $event->model->belongsToMany(Reaction::class, 'post_reactions', 'post_id')->withPivot(
'reaction_id',
'user_id'
);
}
}

Expand Down
26 changes: 18 additions & 8 deletions src/Listener/SaveReactionsToDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,21 @@ public function whenSaving(Saving $event)
$this->validateReaction($reactionType);

if (class_exists('FoF\Gamification\Listeners\SaveVotesToDatabase') && $reactionType == $this->settings->get('fof-reactions.convertToUpvote')) {
app()->make('FoF\Gamification\Listeners\SaveVotesToDatabase')->vote($post, $isDownvoted = false,
$isUpvoted = true, $actor, $post->user);
app()->make('FoF\Gamification\Listeners\SaveVotesToDatabase')->vote(
$post,
$isDownvoted = false,
$isUpvoted = true,
$actor,
$post->user
);
} elseif (class_exists('FoF\Gamification\Listeners\SaveVotesToDatabase') && $reactionType == $this->settings->get('fof-reactions.convertToDownvote')) {
app()->make('FoF\Gamification\Listeners\SaveVotesToDatabase')->vote($post, $isDownvoted = true,
$isUpvoted = false, $actor, $post->user);
app()->make('FoF\Gamification\Listeners\SaveVotesToDatabase')->vote(
$post,
$isDownvoted = true,
$isUpvoted = false,
$actor,
$post->user
);
} elseif (class_exists('Flarum\Likes\Listener\SaveLikesToDatabase') && $reactionType == $this->settings->get('fof-reactions.convertToLike')) {
$liked = $post->likes()->where('user_id', $actor->id)->exists();
if ($liked) {
Expand Down Expand Up @@ -130,10 +140,10 @@ public function pushNewReaction($reaction, $actor, $post, $identifier)
$pusher = $this->getPusher();

$pusher->trigger('public', 'newReaction', [
'reaction' => $reaction,
'postId' => $post->id,
'userId' => $actor->id,
'identifier' => $identifier
'reaction' => $reaction,
'postId' => $post->id,
'userId' => $actor->id,
'identifier' => $identifier,
]);
}

Expand Down

0 comments on commit a49c749

Please sign in to comment.