/** * @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']]); } }
/** * @param Topic $topic */ public function deleteTopic(Topic $topic) { $this->topicDeleter->deleteTopic($topic); }