Cviebrock\EloquentTaggable\Taggable::addOneTag PHP Method

addOneTag() protected method

Add one tag to the model.
protected addOneTag ( string $tagName )
$tagName string
    protected function addOneTag($tagName)
    {
        $tag = app(TagService::class)->findOrCreate($tagName);
        if (!$this->tags->contains($tag->getKey())) {
            $this->tags()->attach($tag->getKey());
        }
    }