protected function addOneTag($tagName) { $tag = app(TagService::class)->findOrCreate($tagName); if (!$this->tags->contains($tag->getKey())) { $this->tags()->attach($tag->getKey()); } }