public function listChannels() { if ($this->channels !== null) { return $this->channels; } $channels = Channel::with('first_topic')->isVisible()->get(); /* * Add a "url" helper attribute for linking to each channel */ $channels->each(function ($channel) { $channel->setUrl($this->channelPage, $this->controller); if ($channel->first_topic) { $channel->first_topic->setUrl($this->topicPage, $this->controller); } }); $this->page['member'] = $this->member = MemberModel::getFromUser(); if ($this->member) { $channels = TopicTracker::instance()->setFlagsOnChannels($channels, $this->member); } $channels = $channels->toNested(); return $this->channels = $channels; }