Level 56
Do you want a user that contains all tags provides, or that contains any of the tags provided?
If any, you could try using ->orWhereJsonContains() to test for each tag.
$provider = User::query()
->where('user_type', 'admin')
->whereRelation('tag', function ($query) use ($followedTags) {
$query->where(function ($query) use ($followedTags) {
foreach ($followedTags as $tag) {
$query->orWhereJsonContains('names', $tag);
}
});
})
->get();
The extra ->where() with a closure, is to wrap all OR WHERE clauses into parenthesis to avoid conflicts with other WHERE clauses.