\App\Http\Requests\AdminMaintainMenuRequest

菜单请求

职责:校验菜单新建/更新入参——父级/类型/名称/路径/组件/图标/排序/状态等; 按菜单类型(目录/页面/外链/容器)附加功能性必填与格式校验。

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

校验规则。

意图:parent_id 可空非负整数;type 仅 1=目录/2=页面/3=外链/4=容器; name/sort 走公共规则;path/query/component/component_name/icon/ tag 可空字符串(各自上限);link_target 仅 _self/_blank; is_keep_alive/is_affix 仅 0/1;status 支持 0/1/2 三态。

Returns

array —

messages()

messages() : array

错误文案。

意图:公共字段走参数化文案,菜单特有字段(类型/父级/路径/组件/组件名) 补充中文提示与格式示例。

Returns

array —

withValidator()

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

按请求场景与菜单类型附加条件校验。

意图:store 时 type/name/parent_id 必填;按类型附加功能性必填与格式 (页面须站内路径+组件,外链须 http(s),缓存页须组件名), 仅当请求带 type(全量提交)时生效,局部更新自动跳过。

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 —