Пример #1
0
 /**
  * SHow all of the likes a post has received.
  *
  * @param int $postId The ID of the post to show the likes for.
  *
  * @return \Illuminate\View\View
  */
 public function getPostLikes($postId)
 {
     $post = $this->postsRepository->find($postId);
     if (!$post) {
         throw new PostNotFoundException();
     }
     $post->load('topic');
     $likes = $this->likesRepository->getAllLikesForContentPaginated($post, $this->settings->get('likes.per_page', 10));
     return view('post.likes', compact('post', 'likes'));
 }
Пример #2
0
 /**
  * @param string $slug
  * @param int    $id
  * @param int    $postId
  *
  * @return \Exception|\Illuminate\Http\RedirectResponse
  */
 public function restore($slug = '', $id = 0, $postId = 0)
 {
     // Forum permissions are checked in "find"
     $topic = $this->topicRepository->find($id);
     $post = $this->postRepository->find($postId);
     if (!$post || !$topic || $post['topic_id'] != $topic['id'] || !$post['deleted_at'] && !$topic['deleted_at']) {
         throw new PostNotFoundException();
     }
     if ($post['id'] == $topic['first_post_id']) {
         $this->topicRepository->restoreTopic($topic);
     } else {
         $this->postRepository->restorePost($post);
     }
     if ($topic) {
         return redirect()->route('topics.showPost', ['slug' => $topic->slug, 'id' => $topic->id, 'postId' => $post->id]);
     }
     return redirect()->route('topics.showPost', ['slug' => $slug, 'id' => $id, 'postId' => $postId])->withErrors([trans('errors.error_deleting_topic')]);
 }