protected function prepareTopicList() { $currentPage = input('page'); $searchString = trim(input('search')); $topics = TopicModel::with('last_post_member')->listFrontEnd(['page' => $currentPage, 'perPage' => $this->topicsPerPage, 'sort' => 'updated_at', 'search' => $searchString]); /* * Add a "url" helper attribute for linking to each topic */ $topics->each(function ($topic) { $topic->setUrl($this->topicPage, $this->controller); if ($topic->last_post_member) { $topic->last_post_member->setUrl($this->memberPage, $this->controller); } if ($topic->start_member) { $topic->start_member->setUrl($this->memberPage, $this->controller); } }); /* * Signed in member */ $this->page['member'] = $this->member = MemberModel::getFromUser(); if ($this->member) { $this->member->setUrl($this->memberPage, $this->controller); $topics = TopicWatch::setFlagsOnTopics($topics, $this->member); } $this->page['topics'] = $this->topics = $topics; /* * Pagination */ if ($topics) { $queryArr = []; if ($searchString) { $queryArr['search'] = $searchString; } $queryArr['page'] = ''; $paginationUrl = Request::url() . '?' . http_build_query($queryArr); if ($currentPage > ($lastPage = $topics->lastPage()) && $currentPage > 1) { return Redirect::to($paginationUrl . $lastPage); } $this->page['paginationUrl'] = $paginationUrl; } }
protected function prepareTopicList() { /* * If channel exists, load the topics */ if ($channel = $this->getChannel()) { $currentPage = input('page'); $searchString = trim(input('search')); $topics = TopicModel::with('last_post_member')->listFrontEnd(['page' => $currentPage, 'sort' => 'updated_at', 'channels' => $channel->id, 'search' => $searchString]); /* * Add a "url" helper attribute for linking to each topic */ $topics->each(function ($topic) { if ($this->embedMode) { $topic->url = $this->pageUrl($this->topicPage, [$this->embedTopicParam => $topic->slug]); } else { $topic->setUrl($this->topicPage, $this->controller); } if ($topic->last_post_member) { $topic->last_post_member->setUrl($this->memberPage, $this->controller); } }); /* * Signed in member */ $this->page['member'] = $this->member = MemberModel::getFromUser(); if ($this->member) { $this->member->setUrl($this->memberPage, $this->controller); $topics = TopicWatch::setFlagsOnTopics($topics, $this->member); ChannelWatch::flagAsWatched($channel, $this->member); } $this->page['topics'] = $this->topics = $topics; /* * Pagination */ if ($topics) { $queryArr = []; if ($searchString) { $queryArr['search'] = $searchString; } $queryArr['page'] = ''; $paginationUrl = Request::url() . '?' . http_build_query($queryArr); if ($currentPage > ($lastPage = $topics->lastPage()) && $currentPage > 1) { return Redirect::to($paginationUrl . $lastPage); } $this->page['paginationUrl'] = $paginationUrl; } } $this->page['isGuest'] = !Auth::check(); }