package subscribeplanrepository

import (
	"errors"
	"legalgo-BE-go/database"

	"gorm.io/gorm"
)

func (s *SubsPlan) GetByID(id string) (*database.SubscribePlan, error) {
	var subscribePlan *database.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
}
