/**
  * @param User $user
  *
  * @return Like
  * @throws Exception
  */
 public function like(User $user)
 {
     if ($this->userLikes($user)) {
         throw new Exception("User already likes that joining");
     }
     $like = new Like(['joinId' => $this->objectOrId, 'userId' => $user->id]);
     if ($like->save()) {
         return $like->fresh();
     }
     throw new Exception("Unable to save like");
 }
 /**
  * @param User $user
  *
  * @return Like
  * @throws Exception
  */
 public function like(User $user)
 {
     if ($this->userLikes($user)) {
         throw new Exception("User already likes that earning");
     }
     $like = new Like(['earntId' => $this->objectOrId, 'userId' => $user->id]);
     if ($like->save()) {
         DB::statement("UPDATE user_earnt_stickers SET likeCount = likeCount + 1 WHERE id = ?", [$this->objectOrId]);
         return $like->fresh();
     }
     throw new Exception("Unable to save like");
 }
 /**
  * @param User $user
  *
  * @return Like
  * @throws Exception
  */
 public function like(User $user)
 {
     if ($this->userLikes($user)) {
         throw new Exception("User already likes that post");
     }
     $post = $this->objectOrId instanceof Post ? $this->objectOrId : Post::find($this->objectOrId);
     $like = new Like(['postId' => $post->id, 'userId' => $user->id]);
     if ($like->save()) {
         $post->likeCount += 1;
         $post->save();
         return $like->fresh();
     }
     throw new Exception("Unable to save like");
 }
 /**
  * @param User $user
  *
  * @return Like
  * @throws Exception
  */
 public function like(User $user)
 {
     if ($this->userLikes($user)) {
         throw new Exception("User already likes that to do");
     }
     $toDo = $this->objectOrId instanceof ToDo ? $this->objectOrId : ToDo::find($this->objectOrId);
     $like = new Like(['toDoId' => $toDo->id, 'userId' => $user->id]);
     if ($like->save()) {
         $toDo->likeCount += 1;
         $toDo->save();
         return $like->fresh();
     }
     throw new Exception("Unable to save like");
 }