验证规则数组 */ public function rules(): array { return [ 'project_id' => 'required|integer|exists:project,id', 'voucher' => 'nullable|numeric|min:0|max:10', 'gender' => 'nullable|integer|in:0,1,2', 'traffic_fee_type' => 'nullable|integer|in:0,1,2', ]; } /** * 获取验证错误消息 * * @return array 错误消息数组 */ public function messages(): array { return [ 'project_id.required' => '项目ID不能为空', 'project_id.integer' => '项目ID必须是整数', 'project_id.exists' => '项目不存在', 'voucher.numeric' => '代金券金额必须是数字', 'voucher.min' => '代金券金额不能小于0元', 'voucher.max' => '代金券金额不能超过10元', 'gender.integer' => '顾客性别设置必须是整数', 'gender.in' => '顾客性别设置值无效', 'traffic_fee_type.integer' => '交通费类型必须是整数', 'traffic_fee_type.in' => '交通费类型值无效', ]; } }