BookStack\Repos\TagRepo::saveTagsToEntity PHP Method

saveTagsToEntity() public method

Save an array of tags to an entity
public saveTagsToEntity ( Entity $entity, array $tags = [] ) : array | Illuminate\Database\Eloquent\Collection
$entity BookStack\Entity
$tags array
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);
    }