public function scopeDiscussionVisibility(ScopeModelVisibility $event)
 {
     // Hide discussions which have tags that the user is not allowed to see.
     if ($event->model instanceof Discussion) {
         $event->query->whereNotExists(function ($query) use($event) {
             return $query->select(app('flarum.db')->raw(1))->from('discussions_tags')->whereIn('tag_id', Tag::getNotVisibleTo($event->actor))->whereRaw('discussion_id = ' . app('flarum.db')->getQueryGrammar()->wrap('discussions.id'));
         });
     }
 }
 public function scopeTagVisibility(ScopeModelVisibility $event)
 {
     if ($event->model instanceof Tag) {
         $event->query->whereNotIn('id', Tag::getNotVisibleTo($event->actor));
     }
 }