\App\Http\Requests\AdminMaintainDeptRequest

部门请求

职责:校验部门新建/更新入参——名称走公共规则,所属公司须存在,部门编码在 组织内唯一,电话/邮箱/传真/部门类型/职责/地点/负责人/地区各自约束; 名称必填,父部门与地区非 0 必须存在。

┌────────────────── 分区导航(按此顺序阅读)──────────────────┐ 分区 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

校验规则。

意图: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。

Returns

array —

messages()

messages() : array

错误文案。

意图:公共字段走参数化文案,部门特有字段(公司/父部门/编码/电话/邮箱/ 传真/部门类型/职责/地点/负责人/地区)补充中文提示。

Returns

array —

withValidator()

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

按请求场景附加条件校验。

意图:POST(store)时 company_id 必填;名称 update 亦必填;parent_id/ region_id 非 0 必须存在(防脏 id);dept_code 组织内唯一(选填, 有值才校验;update 忽略自身,company_id 缺省取现值)。

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 —