package models

import "time"

type UserReview struct {
	ID                 uint       `gorm:"column:id;primaryKey"`
	UserID             uint       `gorm:"column:userId"`
	AstrologerID *uint `gorm:"column:astrologerId"`

	// The session this review is about. NULL on every review written before
	// the rating screen was tied to a session, and on astromall reviews.
	//
	// Without it the admin approving a payout for one consultation is shown
	// the customer's latest review of that astrologer, which may be months
	// old and about a different session entirely.
	ConsultationID *uint `gorm:"column:consultationId"`

	AstromallProductID *uint      `gorm:"column:astromallProductId"`
	Rating             float64    `gorm:"column:rating"`
	Review             string     `gorm:"column:review"`
	Reply              *string    `gorm:"column:reply"`
	IsActive           bool       `gorm:"column:isActive"`
	IsDelete           bool       `gorm:"column:isDelete"`
	IsPublic           bool       `gorm:"column:isPublic"`
	CreatedAt          *time.Time `gorm:"column:created_at"`
	UpdatedAt          *time.Time `gorm:"column:updated_at"`
	CreatedBy          uint       `gorm:"column:createdBy"`
	ModifiedBy         uint       `gorm:"column:modifiedBy"`

	User       User       `gorm:"foreignKey:UserID;references:ID"`
	Astrologer Astrologer `gorm:"foreignKey:AstrologerID;references:ID"`
}

func (UserReview) TableName() string {
	return "user_reviews"
}
