App\Http\Controllers\Forum\TopicsController::reply PHP Method

reply() public method

public reply ( Illuminate\Http\Request $request, $id )
$request Illuminate\Http\Request
    public function reply(HttpRequest $request, $id)
    {
        $topic = Topic::findOrFail($id);
        priv_check('ForumTopicReply', $topic)->ensureCan();
        $this->validate($request, ['body' => 'required']);
        $post = $topic->addPost(Auth::user(), Request::input('body'));
        if ($post->post_id !== null) {
            $posts = collect([$post]);
            $postsPosition = $topic->postsPosition($posts);
            Event::fire(new TopicWasReplied($topic, $post, Auth::user()));
            Event::fire(new TopicWasViewed($topic, $post, Auth::user()));
            return view('forum.topics._posts', compact('posts', 'postsPosition', 'topic'));
        }
    }