src/Services/TagService.php
public function getAllTags($class = null): Collection
    {
        if ($class === null) {
            return $this->tagModel::all();
        }

        if ($class instanceof Model) {
            $class = get_class($class);
        }

        $tagTable = $this->getQualifiedTagTableName();
        $pivotTable = $this->getQualifiedPivotTableName($class);

        $sql = "SELECT DISTINCT t.*
              FROM {$pivotTable} tt 
              LEFT JOIN {$tagTable} t ON tt.tag_id=t.tag_id
              WHERE tt.taggable_type = ?";

        return $this->tagModel::fromQuery($sql, [$class]);
    }
public function getAllTags($class = null): Collection
    {
        if ($class === null) {
            return $this->tagModel::all();
        }

        if ($class instanceof Model) {
            $class = get_class($class);
        }

        $tagTable = $this->getQualifiedTagTableName();
        $pivotTable = $this->getQualifiedPivotTableName($class);

        $sql = "SELECT DISTINCT t.*
              FROM {$pivotTable} tt 
              LEFT JOIN {$tagTable} t ON tt.tag_id=t.tag_id
              WHERE tt.taggable_type = ?";

        return $this->tagModel::fromQuery($sql, [$class]);
    }
Get all Tags for the given class, or all classes.

@param \Illuminate\Database\Eloquent\Model|string|null $class

@return Collection