/**
  * Vote post
  *
  * @param User $user
  * @param Post $post
  * @param $value
  * @return mixed
  */
 public function vote(User $user, Post $post, $value)
 {
     $vote = $this->post->getVote($post, $user->id);
     if (is_null($vote) && $value) {
         $this->post->vote($post, $user->id, $value);
         event(new PostWasVoted($user, $post, $value));
     } else {
         if ($value == 0 || $value == $vote->value) {
             $this->vote->delete($vote);
             event(new PostWasUnvoted($user, $post, $value));
         } else {
             $this->vote->update($vote, $value);
             event(new PostWasVoted($user, $post, $value));
         }
     }
     $post = $this->post->updateVotes($post);
     $owner = $post->user;
     $this->user->update($owner, ['points' => $this->post->userPoints($owner)]);
     return $post;
 }