From e44397dcbb9454f89b8263738d5ccf1e20a12074 Mon Sep 17 00:00:00 2001 From: Vikas Kushwaha Date: Tue, 11 Feb 2025 17:50:21 +0530 Subject: Substituted 'article' with 'project' in filenames --- cmd/web/model/article.go | 52 ------------------------------------------------ 1 file changed, 52 deletions(-) delete mode 100644 cmd/web/model/article.go (limited to 'cmd/web/model/article.go') diff --git a/cmd/web/model/article.go b/cmd/web/model/article.go deleted file mode 100644 index 1475a0c..0000000 --- a/cmd/web/model/article.go +++ /dev/null @@ -1,52 +0,0 @@ -package model - -import ( - "gorm.io/gorm" -) - -type Article struct { - gorm.Model - Slug string `gorm:"uniqueIndex;not null"` - Title string `gorm:"not null" validate:"required"` - Description string `validate:"required"` - Body string `validate:"required"` - User User `validate:"-"` - UserID uint - Comments []Comment - Favorites []User `gorm:"many2many:article_favorite;"` - Tags []Tag `gorm:"many2many:article_tag;"` - IsFavorited bool `gorm:"-"` -} - -func (Article Article) GetFormattedCreatedAt() string { - dateLayout := "Jan 02, 2006" - return Article.CreatedAt.Format(dateLayout) -} - -func (Article Article) GetFavoriteCount() int { - return len(Article.Favorites) -} - -func (Article Article) FavoritedBy(id uint) bool { - if Article.Favorites == nil { - return false - } - - for _, u := range Article.Favorites { - if u.ID == id { - return true - } - } - - return false -} - -func (Article Article) GetTagsAsCommaSeparated() string { - tagsText := "" - - for i := 0; i < len(Article.Tags); i++ { - tagsText += Article.Tags[i].Name + "," - } - - return tagsText -} -- cgit v1.2.3