<?php

namespace App\Http\Requests\QuestionBank\QuestionReception;

use App\Http\Requests\BaseRequest;

/**
 * 充值套餐接口验证
 * @author 唐远望
 * @version 1.0
 * @date 2025-05-19
 * 
 */
class RechargePackage extends BaseRequest
{
    /**
     * 获取应用于请求的规则
     *
     * @return array
     */
    public function rules()
    {
        // 返回结果
        return      [
            'name'                 => 'required',
            'id'                => 'required|integer|gt:0',
            'status'            => 'required|integer|in:0,1',
            'page'              => 'integer|min:1',
            'limit'             => 'integer|min:1',
            'package_name'      => 'required',
            'package_original_price'      => 'required|numeric',
            'package_preferential_price'      => 'required|numeric',
            'package_validity_month'      => 'required|integer',
            'binding_rights'      => 'required',
            'is_automatic_renewal'      => 'required|integer|in:1,2',
        ];
    }


    // 场景列表
    protected   $scenes         = [
        'detail'             => ['id'],
        'list'               => ['page', 'limit'],
        'add'                      => ['package_name', 'package_original_price', 'package_preferential_price', 'package_validity_month','binding_rights','is_automatic_renewal'],
        'edit'                  => ['id','package_name', 'package_original_price', 'package_preferential_price', 'package_validity_month','binding_rights','is_automatic_renewal'],
        'set_status'              => ['id', 'status'],
        'delete'                  => ['id'],
    ];

    /**
     * 获取已定义验证规则的错误消息
     *
     * @return array
     */
    public function messages()
    {
        return [
            'name.required'     => '名称必填',
            'id.required'       => 'ID未知',
            'id.integer'        => 'ID格式错误',
            'id.gt'               => 'ID格式错误',
            'status.required'   => '状态未知',
            'status.integer'    => '状态格式错误',
            'status.in'         => '状态格式错误',
            'page.integer'      => '页码格式错误',
            'page.min'          => '页码格式错误',
            'limit.integer'     => '每页数量格式错误',
            'limit.min'         => '每页数量格式错误',
            'package_name.required'      => '套餐名称必填',
            'package_original_price.required'      => '原价必填',
            'package_original_price.numeric'      => '原价格式错误',
            'package_preferential_price.required'      => '优惠价必填',
            'package_preferential_price.numeric'      => '优惠价格式错误',
            'package_validity_month.required'      => '有效期必填',
            'package_validity_month.integer'      => '有效期格式错误',
            'binding_rights.required'      => '绑定权益必填',
            'is_automatic_renewal.required'      => '是否自动续费必填',
            'is_automatic_renewal.integer'      => '是否自动续费格式错误',
            'is_automatic_renewal.in'      => '是否自动续费格式错误',
        ];
    }
}
