rules()
rules() : array
校验规则。
意图:parent_id 可空非负整数;name/sort/status 走公共规则;行政编码 12 位 数字(code 补格式);拼音/邮编/区号各自上限;经纬度走数值范围 (经度 -180~180、纬度 -90~90)。
地区请求
职责:校验地区新建/更新入参——父级/名称/排序/状态走公共规则,行政编码 12 位数字、拼音/邮编/区号/经纬度各自约束;名称必填、父级非 0 必须存在。
┌────────────────── 分区导航(按此顺序阅读)──────────────────┐ 分区 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 |