package models

import "time"

type Ticket struct {
	ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
	HelpSupportID uint `gorm:"column:helpSupportId;not null;index" json:"helpSupportId"`
	Subject string `gorm:"column:subject;type:varchar(255);not null" json:"subject"`
	Description string `gorm:"column:description;type:varchar(255);not null" json:"description"`
	TicketNumber string `gorm:"column:ticketNumber;type:varchar(255);not null" json:"ticketNumber"`
	UserID uint `gorm:"column:userId;not null;index" json:"userId"`
	IsActive bool `gorm:"column:isActive;default:true" json:"isActive"`
	IsDelete bool `gorm:"column:isDelete;default:false" json:"isDelete"`
	CreatedAt *time.Time `gorm:"column:created_at" json:"created_at"`
	UpdatedAt *time.Time `gorm:"column:updated_at" json:"updated_at"`
	CreatedBy int `gorm:"column:createdBy;not null" json:"createdBy"`
	ModifiedBy int `gorm:"column:modifiedBy;not null" json:"modifiedBy"`
	ChatID *string `gorm:"column:chatId;type:varchar(45)" json:"chatId"`
	TicketStatus *string `gorm:"column:ticketStatus;type:varchar(45)" json:"ticketStatus"`
	// Relations
	User User `gorm:"foreignKey:UserID;references:ID" json:"user"`
}

func (Ticket) TableName() string {
	return "tickets"
}