/** * @param Post $post * @param array $mentioned */ protected function sync(Post $post, array $mentioned) { $post->mentionsUsers()->sync($mentioned); $users = User::whereIn('id', $mentioned)->get()->filter(function ($user) use($post) { return $post->isVisibleTo($user) && $user->id !== $post->user->id; })->all(); $this->notifications->sync(new UserMentionedBlueprint($post), $users); }