rtconner / laravel-tagging

Tag support for Laravel Eloquent models - Taggable Trait
MIT License
882 stars 168 forks source link

retag() Method retags whole tagging_tags table #101

Closed motion-work closed 5 years ago

motion-work commented 8 years ago

I want to update a users tags. For that I am using the retag() method. The retag() method deletes the whole tagging_tags table and inserts the new tags.

Shouldn't it only update the tagging_tagged table? Or am I doing something wrong?

$user = User::find($id);
 $user->retag($request->tags);
haheute commented 8 years ago

when I tested it locally here, it inserted only new and did not delete existing. but that is some weeks ago

haheute commented 8 years ago

possibly... if all of your tags belong to this user... if you then retag.. all would be deleted, i think..

perhaps check the $user with dd($user); and check the taggable_id in the tagging_tagged table

ghost commented 7 years ago

This was happening to me as well, and it turned out to be because the tags were not used and the config value, delete_unused_tags was set to true. Setting delete_unused_tags to false resolved my problem.

lordjoo commented 6 years ago

on mine it says Call to a member function retag() on integer

the code $tags = array("tag 1 updte","tag 2 update"); $post = Post::find($id); $post->retag($tags);

haheute commented 6 years ago

check what $post is, with dd($post); or dump($post); And add use \Conner\Tagging\Taggable; to the Post model.

rtconner commented 5 years ago

Yeah I don't know why delete_unused_tags is true by default. That should not be a default behavior. Setting that to false.