rules()
rules() : array
校验规则。
意图:名称/编码/排序/状态/备注走公共规则工厂;dept_id 可空但须为 存在于 td_sys_dept 的整数(岗位唯一归属一个部门)。
岗位请求
职责:校验岗位新建/更新入参——名称/编码/排序/状态/备注走公共规则, 所属部门须存在;store 时名称/编码/部门必填,编码全表唯一, update 时编码唯一性忽略自身。
┌────────────────── 分区导航(按此顺序阅读)──────────────────┐ 分区 1 · 校验规则 rules 分区 2 · 错误文案 messages 分区 3 · 条件校验 withValidator └────────────────────────────────────────────────────────────┘
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 |