aboutsummaryrefslogtreecommitdiff
path: root/cmd/web/model/comment.go
blob: c979edca2cf0322ead062e0a31a95d6cb8a4a189 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package model

import "gorm.io/gorm"

type Comment struct {
	gorm.Model
	Article   Article `validate:"-"`
	ArticleID uint
	User      User `validate:"-"`
	UserID    uint
	Body      string `validate:"required"`
}

func (Comment Comment) GetFormattedCreatedAt() string {
	dateLayout := "Jan 02, 2006"
	return Comment.CreatedAt.Format(dateLayout)
}