cviebrock / eloquent-taggable

Easily add the ability to tag your Eloquent models in Laravel.
MIT License
537 stars 72 forks source link

Get Model by tag_id #127

Closed rationalthinker1 closed 7 months ago

rationalthinker1 commented 3 years ago

I have a tag_id of a tag that I want to delete. I need the $model for me to detag it. Something like this below.

$tag = Tag::find("tag_id");
$model = $tag->taggable;
$model->tags()->detach( $tag );
cviebrock commented 3 years ago

You would need to set the taggedModels configuration.

That said, it would probably be nice to add a $tagService->deleteTag(...) method that removed the tag and also detagged all the attached models. I'll figure something out shortly.