public function lastTopic($withSubforums = true) { if ($this->lastTopic === null) { $this->lastTopic = [Topic::whereIn('forum_id', $this->allSubforums())->orderBy('topic_last_post_time', 'desc')->first()]; } return $this->lastTopic[0]; }
public function lastTopic($recursive = true) { $key = $recursive === true ? 'recursive' : 'current'; if (isset($this->_lastTopic[$key]) === false) { $this->_lastTopic[$key] = Topic::whereIn('forum_id', $recursive ? $this->allSubforums() : [$this->forum_id])->orderBy('topic_last_post_time', 'desc')->first(); } return $this->_lastTopic[$key]; }
public function unwatchMulti() { $topicIds = explode(',', Request::input('topic_ids')); $topics = Topic::whereIn('topic_id', $topicIds); $unwatchTopics = $topics->get()->filter(function ($t) { return priv_check('ForumTopicWatchRemove', $t)->can(); }); TopicWatch::remove($unwatchTopics, Auth::user()); return ['message' => trans('forum.topics.watch.watched-0')]; }