<?php


namespace App\Http\Requests\QuestionBank\QuestionBackend;


use App\Http\Requests\BaseRequest;

class QuestionTopic extends BaseRequest
{
    /**
     * 获取应用于请求的规则
     *
     * @return array
     */
    public function rules()
    {
        // 返回结果
        return      [
            'title'             => 'required',
            'id'                => 'required|integer|gt:0',
            'question_count'    => 'required|integer|in:4,5',
            'style'             => 'required|integer|in:2,3,6',
            'page'              => 'integer|min:1',
            'limit'             => 'integer|min:1',
            'chapter_id'        => 'required|integer|gt:0',
            'correct_answer'    => 'required',
            'explain'           => 'required',
            'is_high_freq'      => 'required|integer|in:0,1',
            'status'            => 'required|integer|in:0,1',
        ];
    }


    // 场景列表
    protected   $scenes         = [
        'list'                  => ['page', 'limit'],
        'add'                   => ['title', 'style', 'chapter_id', 'correct_answer', 'explain', 'question_count'],
        'edit'                  => ['id', 'title', 'style', 'chapter_id', 'correct_answer', 'explain', 'question_count'],
        'detail'                => ['id'],
        'set_status'            => ['id', 'status'],
        'set_high_freq'         => ['id', 'is_high_freq'],
    ];

    /**
     * 获取已定义验证规则的错误消息
     *
     * @return array
     */
    public function messages()
    {
        return [
            'title.required'                => '标题必填',
            'explain.required'              => '题目解析必填',
            'correct_answer.required'       => '正确答案必填',
            'id.required'                   => 'ID未知',
            'id.integer'                    => 'ID格式错误',
            'id.gt'                         => 'ID必须大于0',
            'page.integer'                  => '页码格式错误',
            'page.min'                      => '页码格式错误',
            'limit.integer'                 => '每页数量格式错误',
            'limit.min'                     => '每页数量格式错误',
            'chapter_id.required'           => '科目ID未知',
            'chapter_id.integer'            => '科目ID格式错误',
            'chapter_id.gt'                 => '科目ID必须大于0',
            'detail.required'               => '考点内容必填',
            'style.required'                => '题目类型未知',
            'style.integer'                 => '题目类型格式错误',
            'style.in'                      => '题目类型格式错误',
            'question_count.required'       => '选项数量未知',
            'question_count.integer'        => '选项数量格式错误',
            'question_count.in'             => '选项数量是4或5',
            'is_high_freq.required'         => '是否高频考题未知',
            'is_high_freq.integer'          => '是否高频考题格式错误',
            'is_high_freq.in'               => '是否高频考题格式错误',
            'status.required'               => '状态未知',
            'status.integer'                => '状态格式错误',
            'status.in'                     => '状态格式错误',
        ];
    }

}