Cartalyst\Tags\TaggableTrait::setTags PHP Метод

setTags() публичный Метод

public setTags ( $tags, $type = 'name' )
    public function setTags($tags, $type = 'name')
    {
        // Prepare the tags
        $tags = $this->prepareTags($tags);
        // Get the current entity tags
        $entityTags = $this->tags->pluck($type)->all();
        // Prepare the tags to be added and removed
        $tagsToAdd = array_diff($tags, $entityTags);
        $tagsToDel = array_diff($entityTags, $tags);
        // Detach the tags
        if (!empty($tagsToDel)) {
            $this->untag($tagsToDel);
        }
        // Attach the tags
        if (!empty($tagsToAdd)) {
            $this->tag($tagsToAdd);
        }
        return true;
    }