tags() public method

Get the Tag models that have been user assigned to this entity.
public tags ( ) : Illuminate\Database\Eloquent\Relations\MorphMany
return Illuminate\Database\Eloquent\Relations\MorphMany
Example #1
0
 /**
  * Save an array of tags to an entity
  * @param Entity $entity
  * @param array $tags
  * @return array|\Illuminate\Database\Eloquent\Collection
  */
 public function saveTagsToEntity(Entity $entity, $tags = [])
 {
     $entity->tags()->delete();
     $newTags = [];
     foreach ($tags as $tag) {
         if (trim($tag['name']) === '') {
             continue;
         }
         $newTags[] = $this->newInstanceFromInput($tag);
     }
     return $entity->tags()->saveMany($newTags);
 }