rules()
rules() : array
校验规则。
意图:类型/引擎仅创建时可选、创建后 prohibited;类型白名单来自注册表 TemplateType;分类可随时调整(nullable + 白名单);编码创建后不可 修改,store 时在类型维度内唯一;主题/正文/变量仅创建可写; name/sort/status/remark 走公共规则。
模板引擎请求
职责:校验模板新建/更新入参——类型/引擎/编码创建后不可修改,主题/正文/ 变量仅创建与发布可写(发布流程是唯一改线上内容入口);编码在类型 维度内唯一(store 时按 (type, code) 组合唯一)。
┌────────────────── 分区导航(按此顺序阅读)──────────────────┐ 分区 1 · 校验规则 rules 分区 2 · 错误文案 messages 分区 3 · 条件校验 withValidator 分区 4 · 内部辅助 templateType └────────────────────────────────────────────────────────────┘
uniqueRule(string $table, string $column, ?int $ignoreId = null, ?callable $where = null) : \Illuminate\Validation\Rules\Unique
同表同列唯一规则。
生成 Laravel 规则:Rule::unique(table, column) 的 unique 约束;ignore 忽略 自身 id(update 场景不与自己冲突);$where 用于 (type, code) 组合唯一等场景。
| string | $table | |
| string | $column | |
| ?int | $ignoreId | |
| ?callable | $where |