Exemple #1
0
 /**
  * @param string       $slug
  * @param int          $id
  * @param int          $postId
  * @param TopicDeleter $topicDeleter
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function delete($slug, $id, $postId, TopicDeleter $topicDeleter)
 {
     // Forum permissions are checked in "find"
     $topic = $this->topicRepository->find($id);
     $post = $this->postRepository->find($postId);
     if (!$post || !$topic || $post['topic_id'] != $topic['id']) {
         throw new PostNotFoundException();
     }
     if ($post['id'] == $topic['first_post_id']) {
         $topicDeleter->deleteTopic($topic);
         return redirect()->route('forums.show', ['slug' => $topic->forum['slug'], 'id' => $topic->forum['id']]);
     } else {
         $this->postRepository->deletePost($post);
         return redirect()->route('topics.show', ['slug' => $topic['slug'], 'id' => $topic['id']]);
     }
 }
Exemple #2
0
 /**
  * @param Post $post
  */
 public function deletePost(Post $post)
 {
     $this->postRepository->deletePost($post);
 }