Files
sm-journal-plugin/models/category.go
Jakub Zych afd0a2cafc feat(15-02): add Categories, Tags, and journal settings admin
Register the remaining YAML admin screens and the settings singleton
so a host can boot Posts, Categories, Tags, and Code journal. Posts
update and delete refuse other authors without access_other_posts.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-06 18:42:29 +02:00

44 lines
1.4 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"`
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", "parent_id"}
}
func (Category) Rules() map[string]string {
return map[string]string{
"name": "required",
"slug": "required",
}
}
func init() {
Register(Category{})
}