コード例 #1
0
ファイル: Taggable.php プロジェクト: waavi/tagging
 /**
  *  Removes the given tags from the model.
  *
  *  @param mixed $tagNames  Array or comma separated list of tags to apply to the model.
  */
 public function untag($tagNames)
 {
     $tagNames = collect(is_array($tagNames) ? $tagNames : explode(',', $tagNames))->map(function ($tagName) {
         return Tag::normalizeTagName($tagName);
     })->toArray();
     $tags = app(TagInterface::class)->whereIn('name', $tagNames)->get()->pluck('id')->toArray();
     $this->tags()->detach($tags);
     return $this->load('tags');
 }
コード例 #2
0
ファイル: Tag.php プロジェクト: waavi/tagging
 /**
  *  Mutator for the name attribute
  *
  *  @param  string $value
  *  @return void
  */
 public function setNameAttribute($value)
 {
     $this->attributes['name'] = Tag::normalizeTagName($value);
 }