'required|string|max:100', 'image_id' => ['required', 'integer', new Exists(SysFileModel::class, 'id')], 'link_type' => 'nullable|integer|in:0,1', 'link' => [ 'nullable', 'string', 'max:500', Rule::requiredIf(fn () => $this->input('link_type', 0) == 0), ], 'category_id' => [ 'nullable', 'integer', Rule::requiredIf(fn () => $this->input('link_type', 0) == 1), new Exists(SysCategoryModel::class, 'id'), ], 'status' => 'nullable|integer|in:0,1', 'sort' => 'nullable|integer', ]; } public function messages(): array { return [ 'title.required' => '轮播图标题是必填的', 'title.max' => '轮播图标题不能超过 :max 个字符', 'image_id.required' => '轮播图图片是必填的', 'link_type.in' => '跳转类型只能是 0(链接)或 1(分类)', 'link.required' => '链接模式下跳转链接是必填的', 'link.max' => '跳转链接不能超过 :max 个字符', 'category_id.required' => '分类模式下请选择分类', 'status.in' => '状态值只能是 0(启用)或 1(禁用)', 'sort.integer' => '排序必须是整数', ]; } }