Пример #1
0
 public function setAsRead($commentId)
 {
     if ((int) $commentId > 0 && !is_null($comment = Comment::find((int) $commentId))) {
         if ($token = $comment->getOwnerToken()) {
             $state = new StateSender($token);
             $state->setCommentAsRead($commentId);
             $state->send();
         }
         return $this->respondNoContent();
     } else {
         return $this->respondWithError('Comment doesn\'t exist');
     }
 }
Пример #2
0
 public function setAsRead($postId)
 {
     if ((int) $postId > 0 && !is_null($post = Post::find((int) $postId))) {
         if ($token = $post->getOwnerToken()) {
             $state = new StateSender($token);
             $state->setPostAsRead($postId);
             Comment::where('post_id', $postId)->get()->each(function ($comment) use($state) {
                 $state->setCommentAsRead($comment->id);
             });
             $state->send();
         }
         return $this->respondNoContent();
     } else {
         return $this->respondWithError('Post doesn\'t exist');
     }
 }