bus = $bus; $this->forum = $forum; } /** * Create a discussion according to input from the API request. * * @param \Flarum\Api\JsonApiRequest $request * @param \Flarum\Api\JsonApiResponse $response * @return \Flarum\Core\Models\Discussion */ protected function create(JsonApiRequest $request, JsonApiResponse $response) { $user = $request->actor->getUser(); $discussion = $this->bus->dispatch( new StartDiscussionCommand($user, $this->forum, $request->get('data')) ); // 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) { $this->bus->dispatch( new ReadDiscussionCommand($discussion->id, $user, 1) ); } return $discussion; } }