public function scopePostVisibility(ScopePostVisibility $event) { // When fetching a discussion's posts: if the user doesn't have permission // to moderate the discussion, then they can't see posts that have been // hidden by someone other than themself. if ($event->actor->cannot('editPosts', $event->discussion)) { $event->query->where(function ($query) use($event) { $query->whereNull('hide_time')->orWhere('user_id', $event->actor->id); }); } }