protected function filterDiscussionVisibleTo($ids, User $actor) { // For each post ID, we need to make sure that the discussion it's in // is visible to the user. if ($actor) { $ids = Discussion::join('posts', 'discussions.id', '=', 'posts.discussion_id')->whereIn('posts.id', $ids)->whereVisibleTo($actor)->get(['posts.id'])->lists('id'); } return $ids; }