statusRule()
statusRule() : string
状态规则。
生成 Laravel 规则:nullable(可空)、integer(整数)、in:0,1(仅启用/停用两态)。
Request 公共字段规则 trait
职责:收敛全站 Request 的 status/sort/remark/name/code 规则与文案, 避免规则集群复制粘贴——一处改、处处改。
┌────────────────── 分区导航(按此顺序阅读)──────────────────┐ 分区 1 · 字段规则工厂 statusRule / sortRule / remarkRule / nameRule codeRule / uniqueRule 分区 2 · 通用文案 commonMessages └────────────────────────────────────────────────────────────┘
用法:use HasCommonRules 后,rules() 里 'status' => $this->statusRule();
文案 array_merge($this->commonMessages('岗位'), [...实体特有...]);
同表唯一 'code' => $this->uniqueRule('td_sys_post', 'code', $id)。
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 |