\App\Http\Requests\AdminConfigPostRequest

岗位请求

职责:校验岗位新建/更新入参——名称/编码/排序/状态/备注走公共规则, 所属部门须存在;store 时名称/编码/部门必填,编码全表唯一, update 时编码唯一性忽略自身。

┌────────────────── 分区导航(按此顺序阅读)──────────────────┐ 分区 1 · 校验规则 rules 分区 2 · 错误文案 messages 分区 3 · 条件校验 withValidator └────────────────────────────────────────────────────────────┘

Summary

Methods
Properties
Constants
rules()
messages()
withValidator()
No public properties found
No constants found
statusRule()
sortRule()
remarkRule()
nameRule()
codeRule()
uniqueRule()
commonMessages()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

rules()

rules() : array

校验规则。

意图:名称/编码/排序/状态/备注走公共规则工厂;dept_id 可空但须为 存在于 td_sys_dept 的整数(岗位唯一归属一个部门)。

Returns

array —

messages()

messages() : array

错误文案。

意图:公共字段走参数化文案,岗位特有字段(名称/编码/部门)补充中文提示。

Returns

array —

withValidator()

withValidator(\Illuminate\Validation\Validator  $validator) : void

按请求方法附加条件校验。

意图:store 时 name/code/dept_id 必填且 code 全表唯一(岗位唯一归属部门, 新增必填);update 且带 code 时唯一性忽略自身。

Parameters

\Illuminate\Validation\Validator $validator

statusRule()

statusRule() : string

状态规则。

生成 Laravel 规则:nullable(可空)、integer(整数)、in:0,1(仅启用/停用两态)。

Returns

string —

sortRule()

sortRule() : string

排序号规则。

生成 Laravel 规则:nullable(可空)、integer(整数,用于升序排序)。

Returns

string —

remarkRule()

remarkRule() : string

备注规则。

生成 Laravel 规则:nullable(可空)、string(字符串)、max:255(最长 255 字符)。

Returns

string —

nameRule()

nameRule(int  $max = 64) : string

名称规则。

生成 Laravel 规则:nullable(可空)、string(字符串)、max(上限按实体可配,默认 64)。

Parameters

int $max

Returns

string —

codeRule()

codeRule(int  $max = 32) : string

编码规则。

生成 Laravel 规则:nullable(可空)、string、max(可配,默认 32)、 regex(字母开头 + 字母/数字/下划线,前后端同正则)。

Parameters

int $max

Returns

string —

uniqueRule()

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) 组合唯一等场景。

Parameters

string $table
string $column
?int $ignoreId
?callable $where

Returns

\Illuminate\Validation\Rules\Unique —

commonMessages()

commonMessages(string  $entity, int  $nameMax = 64) : array

通用字段中文文案。

实体名参数化(如「岗位」→「岗位编码不能超过 32 个字符」),返回字段规则 对应的 messages 数组,供各 Request 与实体特有文案合并。

Parameters

string $entity
int $nameMax

Returns

array —