- Register golem15.journal requiring exactly golem15.translate - Squash golem15_journal_posts DDL with unique slug and JSONB columns - Persist one en/pl Post through translate helpers on real Postgres Co-authored-by: Cursor <cursoragent@cursor.com>
49 lines
1.6 KiB
Go
49 lines
1.6 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// Post is a journal entry stored on golem15_journal_posts.
|
|
type Post struct {
|
|
ID uint `gorm:"column:id;primaryKey"`
|
|
UserID *uint `gorm:"column:user_id"`
|
|
RedactorID *uint `gorm:"column:redactor_id"`
|
|
Title string `gorm:"column:title"`
|
|
Slug string `gorm:"column:slug"`
|
|
Excerpt string `gorm:"column:excerpt"`
|
|
Content string `gorm:"column:content"`
|
|
ContentHTML string `gorm:"column:content_html"`
|
|
PublishedAt *time.Time `gorm:"column:published_at"`
|
|
Published bool `gorm:"column:published"`
|
|
IsPinned bool `gorm:"column:is_pinned"`
|
|
Metadata *string `gorm:"column:metadata;type:jsonb"`
|
|
Sources *string `gorm:"column:sources;type:jsonb"`
|
|
CreatedAt *time.Time `gorm:"column:created_at"`
|
|
UpdatedAt *time.Time `gorm:"column:updated_at"`
|
|
}
|
|
|
|
func (Post) TableName() string { return "golem15_journal_posts" }
|
|
|
|
// MorphName is the PHP class string stored on translate attributes and system_files.
|
|
func (Post) MorphName() string { return `Golem15\Journal\Models\Post` }
|
|
|
|
func (Post) Translatable() []string {
|
|
return []string{"title", "content", "content_html", "excerpt", "metadata", "slug"}
|
|
}
|
|
|
|
func (Post) TranslatableIndexes() []string { return []string{"slug"} }
|
|
|
|
// Fillable is the tracer allow-list. redactor_id, content_html, and user_id
|
|
// are never mass-assigned from a map.
|
|
func (Post) Fillable() []string {
|
|
return []string{
|
|
"title", "slug", "excerpt", "content",
|
|
"published", "published_at", "is_pinned", "metadata", "sources",
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
Register(Post{})
|
|
}
|