Closed bogordesaincom closed 3 years ago
Sorry for the delay.
I'm not sure I understand the issue. $product->tag($tags)
treats $tags
as a comma-delimited string of the actual tags you want to add. In your case, you are asking it to tag the product with the strings "7", "8", "9", etc..
I suspect that "7" is really the id of an existing tag you want to add to the product, yes? I would see if you could update your front end to return the tag names instead of the tag ids you want to add to the models. Then your controller code should work as-is. If you can only return the ids, then you'd need to look up the tags with those ids and tag the models that way. e.g. something like this (untested):
$tagIds = $request->input('tags');
$tagNames = Tag::whereIn('id', explode(',', $tagIds)->get()
->pluck('name')->all();
$product->tag($tagNames);
It's not that pretty, I agree. I will make a note to add a tagById()
method in the next version.
I forgot to mention this, but tagById()
, untagById()
, and retagById()
now exist in the latest version of the package.
Please be sure you include all the relevant information in your issue so we can help you:
When i Store methode is success, and add new.
But In Update Methode Add
tag_id
like7,8,9,10
Like This
How to Solved in Method Edit and Store.
in Edit i setup this :
in Store
Also, please use fenced code blocks when pasting more than one line of code. It makes it so much more readable for everyone!
Thank you!