From 57eb8f6712361a3bf75983ce153fac4846dc0273 Mon Sep 17 00:00:00 2001 From: Vikas Kushwaha Date: Tue, 11 Feb 2025 16:31:08 +0530 Subject: Initial commit --- cmd/web/model/comment.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 cmd/web/model/comment.go (limited to 'cmd/web/model/comment.go') diff --git a/cmd/web/model/comment.go b/cmd/web/model/comment.go new file mode 100644 index 0000000..c979edc --- /dev/null +++ b/cmd/web/model/comment.go @@ -0,0 +1,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) +} -- cgit v1.2.3