get('data.title'); $content = $params->get('data.content'); $user = $this->actor->getUser(); $command = new StartDiscussionCommand($title, $content, $user, app('flarum.forum')); $discussion = $this->dispatch($command, $params); // After creating the discussion, we assume that the user has seen all // of the posts in the discussion; thus, we will mark the discussion // as read if they are logged in. if ($user->exists) { $command = new ReadDiscussionCommand($discussion->id, $user, 1); $this->dispatch($command, $params); } $serializer = new DiscussionSerializer(['posts']); $document = $this->document()->setData($serializer->resource($discussion)); return $this->respondWithDocument($document); } }