package newsrepository

import newsdomain "legalgo-BE-go/internal/domain/news"

func (a *accessor) GetBySlug(slug string) (*newsdomain.News, error) {
	var news newsdomain.News

	if err := a.db.
		Preload("Tags").
		Preload("Categories").
		Preload("Author").
		First(&news, "slug = ?", slug).Error; err != nil {
		return nil, err
	}

	return &news, nil
}
