<?php

namespace App\Http\Requests\QuestionBank\QuestionBackend;

use App\Http\Requests\BaseRequest;

/**
 * 充值套餐接口验证
 * @author 唐远望
 * @version 1.0
 * @date 2025-05-20
 * 
 */
class CommonConfig 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',
            'content_code'      => 'required',
            'content_title'     => 'required',
            'content_detail'    => 'required',
            'content_detail.chinese_medicine_qrcode'    => 'nullable|url',
            'content_detail.western_medicine_qrcode'     => 'nullable|url',
        ];
    }


    // 场景列表
    protected   $scenes         = [
        'detail'             => ['content_code'],
        'list'               => ['page', 'limit'],
        'add'                      => ['content_code', 'content_title','content_detail'],
        'edit'                  => ['content_code', 'content_title','content_detail'],
        'edit_challenge_activities'      => ['content_detail.chinese_medicine_qrcode', 'content_detail.western_medicine_qrcode'],
        'set_status'              => ['content_code', 'status'],
        'delete'                  => ['content_code'],
    ];

    /**
     * 获取已定义验证规则的错误消息
     *
     * @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'         => '每页数量格式错误',
            'content_code.required'      => '内容编码必填',
            'content_title.required'     => '内容标题必填',
            'content_detail.required'    => '内容详情必填',
            'content_detail.chinese_medicine_qrcode.url'    => '中药二维码格式错误',
            'content_detail.western_medicine_qrcode.url'     => '西药二维码格式错误',
        ];
    }
}
