rules()
rules() : array
校验规则。
意图:company_id 可空但须存在于 td_sys_company;parent_id/leader_id/ region_id 可空非负整数;name/sort/status/remark 走公共规则; dept_code/phone/fax 可空字符串(上限 32);email 可空邮箱(上限 64); dept_type 仅 1/2/3;description 上限 1000;location 上限 255。
部门请求
职责:校验部门新建/更新入参——名称走公共规则,所属公司须存在,部门编码在 组织内唯一,电话/邮箱/传真/部门类型/职责/地点/负责人/地区各自约束; 名称必填,父部门与地区非 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 |