\App\Http\Requests\AdminMaintainPermissionRequest

权限请求

职责:校验权限码新建/更新入参——所属菜单/类型/权限码/名称/排序/状态/锁定/ 备注;权限码走「模块:资源:操作」冒号分段格式且全表唯一(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

校验规则。

意图:menu_id 可空但须存在于 td_sys_menu;type 仅 1=菜单/2=按钮/3=接口; code 走「模块:资源:操作」冒号分段格式(上限 64),且按同表同列唯一 (update 忽略自身);name/sort/status/remark 走公共规则;is_editable 仅 0/1。

Returns

array —

messages()

messages() : array

错误文案。

意图:公共字段走参数化文案,权限特有字段(菜单/类型/权限码/名称) 补充中文提示与格式示例。

Returns

array —

withValidator()

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

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

意图:store(permissionStore 路由)时 menu_id/type/code/name 必填。

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 —