eloquent-taggable icon indicating copy to clipboard operation
eloquent-taggable copied to clipboard

Get Model by tag_id

Open rationalthinker1 opened this issue 3 years ago • 1 comments

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 );

rationalthinker1 avatar Jul 10 '21 21:07 rationalthinker1

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.

cviebrock avatar Aug 25 '21 16:08 cviebrock