package subscribeplanrepository

import (
	"errors"
	subscribeplandomain "legalgo-BE-go/internal/domain/subscribe_plan"

	"gorm.io/gorm"
)

func (s *SubsPlan) GetByID(id string) (subscribeplandomain.SubscribePlan, error) {
	var subscribePlan subscribeplandomain.SubscribePlan

	if err := s.DB.First(&subscribePlan, "id = ? ", id).Error; err != nil {
		if errors.Is(err, gorm.ErrRecordNotFound) {
			return subscribePlan, errors.New("subscribe plan not found")
		}
		return subscribePlan, err
	}

	return subscribePlan, nil
}
