Check if Model has specific Spatie Tag

368 Views Asked by At

I'm using Spatie Tags and I have attached a few location tags to the user model. Now I want to see if the users is tagged to a location. Perhaps I can use the Laravel 'contains' function from collections? Things are complicated by the fact that Spatie stores the tags as json data with language.

I tried:

$user->tags->contains('Midtown')

but I get false even though the user has the tag: { "en": "Midtown" }

There must be a built in way to check this but I can't seem to find this in the documentation.

0

There are 0 best solutions below