public function reply(HttpRequest $request, $id) { $topic = Topic::findOrFail($id); $this->authorizePost($topic->forum, $topic); $this->validate($request, ['body' => 'required']); if ($topic->addPost(Auth::user(), Request::input('body'), false)) { $posts = Post::where('post_id', $topic->topic_last_post_id)->get(); $postsPosition = $topic->postsPosition($posts); Event::fire(new TopicWasReplied($topic, $posts->last(), Auth::user())); return view('forum.topics._posts', compact('posts', 'postsPosition', 'topic')); } }
public function reply(HttpRequest $request, $id) { $topic = Topic::findOrFail($id); $this->authorizePost($topic->forum, $topic); $this->validate($request, ["body" => "required"]); if ($topic->addPost(Auth::user(), Request::input("body"), false)) { $posts = Post::where("post_id", $topic->topic_last_post_id)->get(); $postsPosition = $topic->postsPosition($posts); Event::fire(new TopicWasReplied($topic, $posts->last(), Auth::user())); return view("forum.topics._posts", compact("posts", "postsPosition", "topic")); } }