Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "hasTag" method to check if the model has a certain tag #517

Merged
merged 3 commits into from
Oct 3, 2024

Conversation

jimmitjoo
Copy link
Contributor

@jimmitjoo jimmitjoo commented Sep 30, 2024

I have been building this functionality in three projects now, so I think it might be something others could find usable as well.

You can check if a model has a certain tag by its name, or by its ID.

In my case I am currently developing a portal for runners where we list races of different distances, and each race can offer multiple distances. For certain distances we should display some extra options. So we put the distances as tags on the Race model. Now we need a way to check if this race has for example "Marathon", then we should display the map of aid stations, which is not the case for 5k races or shorter.

@AlexVanderbist
Copy link
Member

Nice, thanks for the PR!

@AlexVanderbist AlexVanderbist merged commit 9e7513c into spatie:main Oct 3, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants