isUpdate()) { $unique = $unique->ignore($this->route('id')); } return [ 'name' => ['required', 'string', 'max:50', $unique], 'percent' => 'nullable|numeric|min:0|max:999.99', 'sort' => 'nullable|integer', 'status' => 'nullable|integer|in:0,1', 'icon_id' => ['nullable', 'integer', new Exists(SysFileModel::class, 'id')], ]; } public function messages(): array { return [ 'name.required' => '等级名称不能为空', 'name.max' => '等级名称最长 50 个字符', 'name.unique' => '等级名称已存在', 'percent.numeric' => '价格上浮比例必须为数字', 'percent.min' => '价格上浮比例不能小于 0', 'percent.max' => '价格上浮比例不能超过 999.99', 'status.in' => '状态值不正确', 'icon_id.exists' => '请重新上传图片' ]; } }