protected function handleRequest(Request $request) { $tid = \Route::input('id'); // Fetch some info about the topic $topic = Topic::findOrFail($tid); // Make sure post authors and their groups are all loaded $topic->posts->load('author.group'); $this->data['topic'] = $topic; }
protected function run() { $tid = $this->get('id'); $topic = Topic::findOrFail($tid); $user = User::current(); if (!$topic->subscribers->contains($user)) { $topic->subscribers()->attach($user); $this->raise(new UserSubscribed($topic, $user)); } }