Files
sm-journal-plugin/models/category.go
Jakub Zych f22d08902e feat(admin): edit category content in the admin form behind the HTML gate
- add a content textarea (size huge) after description, with en and pl phrases
- add content to Category.Fillable
- export classes.CheckHTML and run it from FormBeforeCreate and FormBeforeUpdate:
  unsafe category content answers 422 on content, blank content is stored as NULL
2026-10-09 16:26:12 +02:00

45 lines
1.5 KiB
Go

package models
import "time"
// Category is a journal category stored on golem15_journal_categories.
type Category struct {
ID uint `gorm:"column:id;primaryKey"`
Name string `gorm:"column:name"`
Slug string `gorm:"column:slug"`
Code *string `gorm:"column:code"`
Description *string `gorm:"column:description"`
Content *string `gorm:"column:content"` // HTML body (D-21): stored and served as is, not translatable
ParentID *uint `gorm:"column:parent_id"`
NestLeft *int `gorm:"column:nest_left"`
NestRight *int `gorm:"column:nest_right"`
NestDepth *int `gorm:"column:nest_depth"`
CreatedAt *time.Time `gorm:"column:created_at"`
UpdatedAt *time.Time `gorm:"column:updated_at"`
}
func (Category) TableName() string { return "golem15_journal_categories" }
// MorphName is the PHP class string stored on translate attributes.
func (Category) MorphName() string { return `Golem15\Journal\Models\Category` }
func (Category) Translatable() []string { return []string{"name", "description", "slug"} }
func (Category) TranslatableIndexes() []string { return []string{"slug"} }
// Fillable is JOURNAL-002: nest_* stay out of mass assignment.
func (Category) Fillable() []string {
return []string{"name", "slug", "code", "description", "content", "parent_id"}
}
func (Category) Rules() map[string]string {
return map[string]string{
"name": "required",
"slug": "required",
}
}
func init() {
Register(Category{})
}